logo

Palette - Make it Colorful🎨

Palette - Visual Page Builder, no design degree required.

Live Demo Download Palette

Scroll

Creating block in Drupal module programmatically

13/04/2025, by Ivan

Menu

Unlike in Drupal 7, creating multiple instances of a block to place on your site is a simple task in Drupal 8.

This tutorial will teach you how to programmatically add a block to the block layout interface, how to add an (administrative) configuration form to the block, and how to handle it. Finally, you’ll learn how to define and display default configuration values for the form.

Before starting this step-by-step guide, prepare your module skeleton as described in “Prepare the module skeleton.”