Drupal 8: How to write a simple custom “block module”
By Alvin Alexander. Last updated: June 24 2016
Table of Contents
- Goals
- Backup your database
- Check my code out of Github, or create a module directory
- Create a project info YAML file
- Create the necessary subdirectories
- Write the code to display your block
- Clear the caches
- Enable the module
- Place the block module
- See the custom block on your website
- The biggest problem I encountered
- The source code
- Summary
In this tutorial I’ll demonstrate how to write a simple Drupal 8“block module.” By this I mean that I’ll show you how to write a simple Drupal 8 module that will display output in a block. When you’re done you will have created a new block that you can place in one or more theme regions.