How to Use Block Library in WordPress?
WordPress has lots of hidden tricks to get your quickly done. For example, you can copy the entire post content with single click or manage reusable blocks like posts page. Block library is another trick available with Gutenberg block editor. In addition to adding single blocks and patterns, WordPress also allows you to install blocks from third-party developers. Here we will explain how to use block library in WordPress to install blocks quickly.
What is Block Library?
You will be knowing that WordPress offers repository for plugins and themes. They are free for personal and commercial use offered under GPL license similar to WordPress software. With Gutenberg block editor is evolving fast, now WordPress also offers a block library.
- However, unlike theme / plugin, there is no separate repository for blocks.
- WordPress uses the same plugin repository and allows developers to create custom Gutenberg blocks and offer them as a plugin.
How to Use Block Library?
Follow the below instructions if you want to try out block library feature on your WordPress site.
- Login to your WordPress admin panel and navigate o “Posts > Add New” section.
- Make sure you are using the default Gutenberg block editor and not using the Classic Editor plugin.
- When you are in Gutenberg block editor, click on the + icon on top left corner of the editor.
- Let’s say you want to install an accordion block that is not available as part of standard Gutenberg blocks.
- Type “accordion” in the search box and wait for a moment.
- Since, there are not default blocks available, WordPress will search from the plugin repository and suggest the options.
- Check the suitable blocks and click on “Add block” button.
- WordPress will try to install the block and you should be seeing the button shows “Adding”.
- After successful installation, you can view the block under “Blocks” section under “Uncategorized” group.
Adding Content Using Custom Block
After installing a custom block, WordPress will insert that block instantly on your content area. You can also search the block by using / and type the name. In our example, we can filter the block by typing /accordion.
Now that you can add accordion without leaving the editor and publish your post.
What Happens in the Background?
As mentioned, block library simply uses the plugin repository to install a plugin that offers integration inside Gutenberg editor. If you install any blocks within the editor, WordPress will install the plugin in the background. You can go to “Plugins > Installed Plugins” section to view the newly installed plugin on your site. In our case, you can see there is a “Hot Accordion” plugin installed corresponding to the accordion block we have added in Gutenberg editor.
Why You Should Try Block Library?
The biggest advantage of block library is that you need to leave the editor when preparing your post. Earlier, the workflow of installing a plugins was like below:
- Save the current post and navigate to “Plugins > Add New” section.
- Search among thousands of plugins and find relevant one.
- Install the plugin and activate it.
- If the plugin offers settings page, go that menu item and configure the plugin for using on your site.
- Go back to the post and insert the plugin relevant content.
Now, you do not need to follow this hassle process. Block library helps you to search and install the blocks within the editor so that you can continue focus on the content. If you really need a custom block that is not part of standard Gutenberg blocks, then try to use block library within the editor.
Caution Using Block Library
Too many plugins can slow down your website and cause lots of maintenance task for keeping them up to date. Therefore, avoid installing too many blocks from the library without understanding the fact that each block actually installs a plugin to your site. In addition, accidentally deactivating the plugin will delete the content from the post. In our example, deleting the “Hot Accordion” plugin will remove all accordion content on the site. Therefore, you have to keep the plugins active in order to keep the content created with the blocks. This may be a complex workflow for some users to understand.
What Will be the Future?
WordPress introduced Gutenberg as part of version 5.0. If you have noticed the releases after version 5.0, there are improvements in Gutenberg block editor in every single release. Therefore, you can expect the same trend to continue for some more years till the time Gutenberg is matured and widely used among users. Though there are very less plugins offer block library route, you can expect it to grow over the period. Probably, the plugins repository may also change to blocks repository and you can install the items directly from Gutenberg editor.