I have a menu with a "Home" link which was "provided by the Standard module. The title and path cannot be edited."

I am trying to alter the text/link using my module's links.yml file like so:

  title: 'Home Test'
  route_name: '<front>'
  menu_name: main

However this has no affect on the menu link. Other entries in this file work just fine.

Is it possible to alter the link in this way, or is the only option to use one of the menu hooks such as hook_menu_links_discovered_alter

  • do you found the solution? – Adrian Cid Almaguer Feb 12 '18 at 16:23
  • Thank you, your answer was correct. It wasn't working at first due to a permissions problem. I was just hoping it could be changed directly in the yml links file. – Alexander Holsgrove Feb 12 '18 at 16:36

I usually use this the hook_menu_links_discovered_alter() in this way:

 * Implements hook_menu_links_discovered_alter().
function YOUR-MODULE-NAME_menu_links_discovered_alter(&$links) {
   // Changing the title.
   $links['standard.front_page']['title'] = 'Hi';
   // Changing the route.
   $links['standard.front_page']['route_name'] = 'block.admin_display';

But it seems that there are another ways in How to update a menu link created with MenuLinkContent::create()? and How do I programmatically update or delete menu items?

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.