Best practices

Last updated on
3 April 2024

Only enable the blocks you really need

Not all blocks might come with great styling in your theme. Some might even look broken. And: Too many blocks makes Gutenberg harder to use.

Prepare your theme

Gutenberg works with any theme, but not all blocks will work perfectly out-of-the-box. The most common adjustments are:

  • Implement support for alignment classes (full width, etc)
  • Create a color palette
  • Compare the block styling you see in the editor with the actual frontend and see what might be missing

Building custom blocks

Before building custom blocks

We usually end up building some custom blocks in all Drupal Gutenberg projects, but we always think twice about making our custom variations of Gutenberg core blocks. Though it is useful, consider the future maintenance costs. A block itself currently can't be extended so future updates of these blocks must be done manually.  

Example: You want an extra option for the Gutenberg block that handles regular text paragraphs. You create your custom block to replace the core text block functionality, and deactivate the Gutenberg core text block. The problem could show up a few months later when the core block gets a nice feature in an update and you'll need to manually merge the code for that feature into your custom block. Ok for a few blocks, but expensive if it's for all your blocks.

New features coming soon

A lot of improvements are happening with the Gutenberg core now (Sept. 2021) and should soon be something you'll see in a new module release. They you'll be able to do things like deciding which features should be available as options for example in the Gutenberg core image block.

Build for the open web

When building a custom block, please consider sharing it with the community via Gutenberg Cloud.

Block design

Make sure you get to know the block design best practices for Gutenberg blocks.

Be careful with making the blocks too flexible. It's usually better to have a few specified fields in your block, instead of allowing all kinds of blocks to be nested inside it - simply because the block can be hard to use, and it will be difficult to remember how the block was designed to be used.

Help improve this page

Page status: No known problems

You can: