Skip to main content
Dublin Library

The Publishing Project

New research into block development

 

While researching block-based themes I found more information about blocks themselves and how to write them in a way you can submit them for inclusion in the WordPress directory. Most, if not all our blocks, will not be dynamic so we won't cover them in this post, just mention them in case that's what you're looking for. See [creating dynamic blocks](https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/creating-dynamic-blocks/) for more information ## Creating blocks with external metadata [The block type metadata](https://developer.wordpress.org/block-editor/developers/block-api/block-metadata/) provides an external means to declare our block API that will also be necessary if you decide to submit it to the [block directory](https://wordpress.org/support/article/block-directory/). The metadata is stored in a `block.json` file. An example, taken from a demo I'm working on looks like this: ```json { "apiVersion": 2, "name": "rivendellweb/book", "title": "Book", "category": "rivendellweb-blocks", "icon": "smiley", "description": "Example block for a hypothetical book block.", "supports": { "html": true }, "textdomain": "rivendellweb-blocks", "editorScript": "file:./build/index.js", "editorStyle": "file:./build/index.css", "style": "file:./build/style-index.css" } ``` There are two ways to register the block. The first one is to register the block on its own folder using something like the code below: ```php Edit on Github