While working on my Gutenberg Editor Development Course I stumbled upon a cool feature for Gutenberg Blocks that let’s someone to find your block using words not found in the title of your block.
Searching for Blocks in Gutenberg
One of the easiest ways to find a specific block in Gutenberg is by using the search field. By default, if your title has a keyword someone searches for, it will show your block in the results.
Sometimes though, we want our block to show for keywords that are not included in our title.
You can see in the example above that if we search for an “Image” block we get blocks that do not have “Image” in the title.
This is accomplished using the “keywords” parameter when registering your block.
Using the Keyword Setting When Creating a Block in Gutenberg
When you create a block using registerBlockType() you can set a parameter called “keyword.” This parameter takes an array of words that if searched for, will include your block in the results.
In the example above we have added extra keywords to a custom block.
Here is the code to make this work. (Notice we are also escaping them using the wp.i18n library for localization).
This allows us to have our block show up for the search terms “zac,” “fire,” and “fuego,” which are not found in our block title.
I would suggest looking at what keywords the default WordPress blocks use and leverage some of those keywords in your blocks.
Learn More About Gutenberg Development
If you would like to learn more about creating custom blocks or developing with Gutenberg in general, please check out my Gutenberg Development Course!