1

I've seen numerous questions on how to address this, but I've not quite found the answer. I'd like to add an additional link to the main menu. I've attempted this in my_module.links.menu.yml and run drush cr. This doesn't seem to limited impact.

This item will show up under the Tools menu, but not main.

my_module.list:
  title: 'List All Computers'
  description: 'Show all known computers'
  route_name: my_module.listAllComputers
  parent: main

Is there something wrong with the above? Is PHP a better way to add a link to the main menu? If so, where? Do I use a Drupal 8 hook?

1

You are missing the key menu_name that will permit the addition of your new menu item into your main menu.

my_module.list:
  title: 'List All Computers'
  description: 'Show all known computers'
  route_name: my_module.listAllComputers
  parent: main
  menu_name: main

The parent key is not mandatory, so if you want your link to be shown on the first level of your main_menu, you don't need it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.