The WordPress Gutenberg block editor empowers web developers to build a custom content creation experience. Through the use of custom blocks, it’s possible to add just about any sort of layout or functionality to your website.
However, just because we can create a custom block doesn’t mean it’s always necessary. There may be cases where hacking your theme could be an acceptable solution. Not to mention the possibility that a block you need already exists somewhere out on the interwebs.
So, how do you determine whether a custom Gutenberg block is the best answer? It’s all about asking the right questions.
Follow this handy guide for everything you need to consider!
What Is the End Goal?
It might sound counterintuitive, but the best place to start is at the very end. Whatever type of feature you need, think about its purpose and what it should achieve.
You might, for example, be looking for a way to create a complex layout. Or maybe you need a tool that helps you list a specific set of blog posts. Then there are niche features such as displaying editable user profiles and image galleries.
The good news is that a custom Gutenberg block could theoretically do any one of the above examples. This speaks to their versatility.
Yet it is also worth asking if your end goal is unique enough to require something built from scratch. There is a growing library of readymade blocks that can easily be added to your site. They may provide exactly the functionality you’re looking for.
But readymade isn’t always better. If the existing options don’t give you the level of control you seek, then a custom block is the way to go.
Do You Need the Feature in Multiple Places?
One of the great aspects of the block editor is the ability to use the same features again and again. A block can be implemented in any position within a page. And a page can even house multiple instances of the same block.
Likewise, a block can be used across your website. Take, for example, a block that lists staff members. If your business has multiple locations, you could give each one its own page. From there, a custom block could be utilized to list staff at a particular location.
In this case, a custom block could help you maintain both a consistent look and streamline content management. Each location could be easily updated – and even automated to a degree. By pulling posts from a custom post type, new staffers can be added, edited or removed as needed.
Keeping the look and layout you want is also possible. By pairing your blocks with a custom block pattern, you’ll have an extra measure of control. Blocks can also be moved around with very little effort. Thus, adding content above, below or beside your custom block won’t require any template hacking.
A one-off feature, however, may lessen the need for a custom block. In this case, it may be more efficient to use custom fields or add what you need directly to your theme’s template.
Should Clients Have Access to Make Changes?
WordPress Gutenberg blocks are built with ease-of-use in mind. They’re easy to move and edit to suit your needs. This enables anyone to make changes without too much trouble.
Of course, this can be a headache for web developers. You may not necessarily want your clients to go in and change things around. It could throw off the consistency of your design or lead to the wrong content being displayed.
The WordPress Block API allows for some protections in this area, such as allowing single instance usage and even locking templates. Still, there may be times when hiding functionality is the better option.
If you really don’t want anyone to view or have access to specific functionality, stash it in your template or a custom plugin. This will client-proof your site and ensure that it works the way you intended.
What Will the Future Bring?
Finally, it’s always worth considering what future needs may arise. This is particularly important when it comes to Gutenberg, as it is likely to be the default editor for the long haul.
That means blocks need to be built in a sustainable way. But this is made more difficult by the evolution of the editor itself and the tools we use to build for it. Some coding methods have changed since the early days, and it is likely they’ll do so again.
Then there’s also a debate about building blocks natively versus using a plugin. Before committing to a particular plugin, think about its long-term potential. It’s best to look for plugins with a solid track record and a likeliness to still exist years from now.
And if you do decide to go with an old school (non-block-based) approach to building features, it’s vital to consider how that will hold up. Themes may trend towards being fully-editable within Gutenberg sooner rather than later. How does that affect what you’re doing now?
Finding the Best Fit for Gutenberg
Custom blocks offer an opportunity to create something that is both unique and reusable. Even better, they can be built in a way that meshes perfectly with the editor itself. The result is a seamless experience for users.
But before you jump in head-first, you’ll want to do a little thinking. Ask yourself the questions above and determine whether a custom block is the right fit.