Step by step tutorial: Hello World

A step-by-step tutorial for building a module called "Hello World"

Tutorial introduction

Introduction to the Hello World module

Prepare a Module skeleton

Obtaining git code as the starting point, or 'skeleton,' for module development

Add a routing file

Back in your module's root folder, where the .info.yml file is located, add a new file called hello_world.routing.yml and add the following

Adding a basic controller

The content() function in the HelloController class will be returning the markup text, when the routing system invokes the page.

Add a menu link

Now that we have created a placeholder for our module settings page, let us add a menu link for it. The instructions below show how to

Add a Default Configuration

By adding a single settings yaml file to our module, Drupal will automatically load the contents of that yaml file, and we can access it to

Going further

For the truly adventurous, these code examples are the abridged version of the full page example from the Examples module.