Jeff Chandler posted an interesting question on Twitter several days ago. The idea was to have a “template” for his podcast show notes so that he wouldn’t have to rehash the same sections each time. This question stuck with me, and it became apparent that it was very possible to create a sort of faux template using the built-in “reusable blocks” feature with the WordPress block editor.
A lot of this is not intuitive at this point and might take some digging for someone not intimately familiar with all the block editor features. But, this is an extremely powerful feature that I’m sure will become more useful in the future. I can even see things like theme authors sharing reusable blocks to help users build out certain page designs.
In this tutorial, I’m going to focus specifically on creating a reusable template with your own blocks.
What are reusable blocks?
The WordPress block editor allows you to create and save a block to reuse over and over. Blocks are stored as posts of a custom post type, but that’s not particularly important. It’s just data that can be used elsewhere.
The idea is that you create something once that may go into multiple posts or pages on your site. However, you can manage it from a single location. You can access this somewhat hidden management page via the
wp-admin/edit.php?post_type=wp_block page in your WordPress admin.
What we’re doing in this tutorial is taking that concept and creating a faux template using the built-in reusable block system.
Creating a reusable template
This is no different from creating a reusable block. Go to your editor and insert any block that you might want to reuse. Then, click on the “More Options” icon (three vertical dots). You should see an “Add to Reusable Blocks” option. Click this, type a name for your reusable block, and save.
Doing this will allow you to reuse the block in any post going forward.
When I think of “templates,” the idea is not to reuse a single block. It’s to have multiple blocks in place and ready to go. The block editor has you covered with this too. Just select multiple blocks and use the same process outlined above.
For the purposes of this tutorial, I added an empty Cover (full alignment), Paragraph, and Heading block. This is a pattern that I like to use sometimes. And, I’ll make this available to download at the end of the post if you want to import it.
Your “templates” can be anything though. It’s just a consistent pattern that you’ll want to use later.
Reusing the templates in posts
This is the point where we go from “reusable blocks” to “reusable templates.”
When creating a new post, Click the “+” symbol to add a new block. Select the “Reusable” section and find the block you saved (I named mine “Template: Cover + Article”). Then, insert that block.
Once the block is inserted, you can’t edit it by default. You must convert it. Click on the “More Options” icon for the block you just inserted. Then, click the “Convert to Regular Block” option.
From this point, you’re set up. You can now edit any of the blocks in the post.
While this may seem a little complex at first, it’s really easy once you’ve done it a few times and developed the muscle memory for it. I’ve only done it a handful of times, and it feels pretty natural.
Importing reusable blocks
On the block management page, there’s an “Import From JSON” button at the top of the page. This actually allows you to import reusable blocks that others have created or move some from one WordPress install to another. You can also export individual reusable blocks from the same page.
I’ve made a quick reusable Cover + Paragraph + Heading block if you want to give it a whirl. Download Example JSON.
Note that I had to save the above file as a ZIP. Unzip on your computer and upload the
template-cover-article.json file and not the ZIP folder.