Gutenberg Contributors Propose Renaming Reusable Blocks

WordPress’ Reusable blocks may soon be getting re-named, as the feature’s distinct capabilities are less recognizable from its name following the introduction of patterns.

When the Gutenberg project first took off, nobody had any idea how important patterns would become in the page building experience, or that they would be getting their own directory on WordPress.org. During a demo at WordCamp Europe 2021, Gutenberg lead architect Matías Ventura commented on how transformative patterns have been for making page design approachable for users.

“Perhaps it was a smaller part of the roadmap initially but it’s becoming a centerpiece – especially because it allows…world class designers to provide a starting point for users and users get to learn design as they are interacting with themes,” Ventura said. 

A year later, patterns have made their way to the forefront of theme design and development with an excitement that rivals the introduction of widgets in WordPress’ earlier days. WordPress 5.9 will feature pattern insertion directly from the Pattern Directory so users will be able to change their patterns as often as they like, without having to switch themes. Coming in Gutenberg 11.8, the pattern inserter will highlight featured patterns from the directory in the initial view, instead of displaying the first alphabetical category. Contributors are also considering a path for allowing themes to surface specific patterns from the directory instead of bundling them.

In light of all this activity around Patterns, Reusable blocks are in need of a renaming that is more descriptive.

 “In the end, patterns are also reusable pieces of design,” Ventura said.

“Given the nature of these [Reusable] blocks is to have content in sync wherever it’s displayed — edit once; update everywhere — I propose we change the name in the UI to ‘Synced Blocks’ and adjust the block description a little bit to clarify that.”

The UI for Reusable Blocks is confusing because it is built on top of assumptions that users know the intricacies of how they work. WordPress developer Lee Hodson summarized the problem and how the current UI leads to reusable blocks being accidentally edited:

The save reusable blocks dialog is nice but how many creators actually understand what this save dialog means? On the surface it looks as though everyone should understand the save/not save option but it’s meaning is only obvious when you understand that reusable blocks are (currently) meant to either (a) not be edited or (b) edits to them are meant to affect all instances of the same block and (c) that reusable blocks can be converted to editable blocks (and not everyone immediately understands the difference) when edits to reusable blocks are meant to be independent of the block’s template.

I feel that a nice idea (reusable blocks) has been very badly implemented and many creators are blissfully unaware of its pitfalls until they realize their ‘template blocks’ have been overwritten.

Several contributors participating in the renaming discussion concurred that “Synced Blocks” would be a better name for the feature. This suggestion is the frontrunner so far. The conversation is still open and consideration of this proposal has been added to the Reusable Blocks Improvements tracking issue.

Gutenberg 11.6 Introduces New API for Locking Blocks

Gutenberg 11.6 was released this week with a new API for managing lock control at the block-type level. When defining a block, developers can now use the lock attribute to designate whether a block can be moved or removed. The PR introduces parts of the locking support mechanisms proposed by Matias Ventura in a separate issue earlier this year.

Ventura explained that while the editor already has template locking support to prevent inserting or moving blocks (i.e. for custom post type templates), it doesn’t yet offer much granular control or a UI for the different locking states. He identified block themes as an important use case for establishing a new block-level API for representing lock status. Block themes may necessitate the ability to lock down key elements, such as preventing the removal of the post-content for a single post template. If you have ever played around with the template editor then you have likely discovered how easy it is to remove important elements by accident.

“Another use case that we’re building for is having a Checkout Block with different blocks that act as fundamental steps,” WooCommerce and Gutenberg engineer Seghir Nadir said. “We don’t want people to delete or move those steps since they’re fundamental and their order is also important, but we want to allow people to select them, access settings, and insert blocks in between them.”

During this week’s core editor chat, Paal Joachim Romdahl highlighted the need for a locking mechanism for Reusable blocks.

“At the moment it is too easy to make an accidental change to a Reusable block,” Romdahl said. “I worry that only having the hover overlay and the initial click [to] select the parent Reusable block is just not good enough, that we soon should get a lock mechanism in place. There is a lot of feedback from users who have accidentally deleted the inner contents of the blocks and wondered what happened.”

Romdahl has created several issues about to the possibility of adding a locking mechanism to the inline toolbar for reusable blocks, where users would need to unlock to edit the contents.

Now that the foundational infrastructure is in place for managing lock control at the block-type level, contributors can begin building a UI to control it, as outlined in the Locking and TemplateLocking issue. Ventura said future iterations should include a UI that indicates which blocks are user-editable and also display block status in the list view and block inspector.

Experimenting With Reusable Blocks to Create Post Templates

For the past several years, I’ve used the Post Template plugin developed by Vincent Prat to create and manage post templates. For example, some of the information in the WordPress Weekly and In Case You Missed It posts never changes and instead of manually entering it each time, it’s nice to use a template where only a few changes are necessary.

The other day, I was wondering if I could use the reusable block feature in Gutenberg to replace the plugin. Justin Tadlock reached out and provided me a reusable block template JSON file that I imported into Gutenberg. By the way, if you successfully import a block into WordPress, the block won’t appear until you manually refresh the page.

The reusable block template approach works fairly well. However, I noticed that I was unable to add a block inside the reusable block. When I tried, a red line was displayed and any blocks that were inserted were removed.

Red Means No

I understand that reusable blocks are meant to be restricted templates where changes are distributed across a site to wherever the block is displayed. But it’s still a bummer that I can’t add a block inside the template for a singular purpose if a need arises.

One other thing I noticed is that reusable blocks are custom post types. While there is a link to manage them within the reusable block selector, there isn’t a dedicated item within the admin menu. Unless you know the location of the management link, adding and managing them can be a bit more time-consuming.

If you want a quick shortcut to the reusable block management screen, add this to the URL after your domain name. wp-admin/edit.php?post_type=wp_block

I think I’ll experiment with reusable blocks a bit more but as long as they’re not changing often, I believe they’ll make a nice replacement for the Post Templates plugin. What use cases have you encountered where reusable blocks were the solution?