On this page
Create custom blocks
The Gutenberg editor gives a lot of options out of the box, but to really harness the power Gutenberg gives you, a custom block written in a ReactJS syntax, wrapped with the Gutenberg block API is the way to go.
This does not only let you create the block as standard HTML, CSS and JS, but you can also use the powerful Gutenberg block API to create rich and advanced user interfaces.
The best way to quickly get started to create your own custom blocks is to use the provided Example block sub-module.
You'll need NodeJS (and NPM) installed for Javascript and CSS transpiling tools.
- Copy the
gutenberg/modules/example_blockfolder to your custom modules folder and rename it. In our case, we're usingmodules/custom/my_custom_blocks - Rename
example_block.*.ymlfiles tomy_custom_blocks.*.ymlandpackage.example.jsontopackage.json - Rename
example_blockreference tomy_custom_blocksonmy_custom_blocks.gutenberg.ymlandpackage.jsonfiles - Run
npm installon themy_custom_blocksfolder - Activate the
my_custom_blocksDrupal Module - Run
npm run buildon themy_custom_blocksfolder to create the new js Code - Run
npm starton themy_custom_blocksfolder to continues watch changes during development - The new Block is now available. Search for the Block Title
This should be the file structure of your newly created module:
![]() |
Resources on custom block development
- Blocks (WordPress/gutenberg.git docs)
- Writing Your First Block Type (WordPress.org docs)
- Your best friends: RichText and InnerBlocks components
- Also you can check how core blocks are implemented. Find a middle term between reusing core blocks, their style or their functionalities and creating blocks from scratch.
For more details on how to build advanced blocks visit https://developer.wordpress.org/block-editor/developers/block-api/
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion
