Drupal - Non-Clickable Menu Items

You need to use route:<nolink> to achieve this. Then it will validate and render without a link.


To create a menu item without link in a custom module add to [module_name].links.menu.yml:

url: 'internal:##'

You need to add a second # character (or any other letter or word url: 'internal:#nolink') in order to the href attribute will not rendered empty, which will cause a page reload if the user click the link.


  • https://www.drupal.org/project/link_attributes
  • or https://www.drupal.org/project/menu_link_attributes

and add class or style for item [a style="pointer-events:none; cursor:default; text-decoration:none;" ...][/a]

pointer-events:none; cursor:default; text-decoration:none;

Tags:

Navigation

8