Add a menu link

Last updated on
14 December 2016

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 create a menu link to the hello_world module in the Development section of the Admin>>Configuration page (http:///admin/config).

In the root folder of your module, create a new file, called and add the following to it:

  title: 'Hello module settings'
  description: 'example of how to make an admin settings page link'
  parent: system.admin_config_development
  route_name: hello_world.content
  weight: 100

Note that the first line is reserving a named space, just like our routing file example. Also note the use of our route name on the 5th line (we use the named space from the first line of the routing file example). The title and description will be displayed in the Development section. Notice that parent line describes the parent link for the menu. In other words, the menu link will be created under admin, config, development.

This will add a link to the path referenced in hello_world.content (hello_world.routing.yml in this example) within the administration pages of your site under the Configuration tab (admin->config) in the Development section. You will need, of course, to clear your cache for the change to take effect.

After you have cleared the cache, you will find a menu link "Hello module settings" in the Development section of Configuration page. On clicking the link, the hello_world module will be called.