I am trying to add an internal link to admin toolbar but I am not able to achieve it.

According to documentation we add an internal link in *.links.menu.yml in the below manner but the link is not being appeared in the toolbar.

  title: 'Hello module settings'
  description: 'example of how to make an admin settings page link'
  parent: system.admin_config_development
  url: internal:/node/123

I tried the following variants as well but none works. url: 'internal:/node/123' or uri: internal:/node/123 or uri: 'internal:/node/123' .

But the following works url: http://localhost/node/123 .

Can anyone suggest me a way to create a menu link in *.links.menu.yml file.

Use case : I want to provide easily accessible link to user to access one particular page. It is not a route. I am aware of other way to create menu link by using MenuLinkContent::create method. But trying to figure out why above method is not working.


I don't know thy this doesn't work (it is a valid input for Drupal\Core\Url::fromUri), but /node/123 actually has a route:

  route_name: entity.node.canonical
    node: 123

Even though they are valid inputs, it is generally a good idea to avoid internal: URLs if you can use something better. "Something better" is either a route name (in the context of links.yml files) or an entity scheme entity:node/123 (in the context of storing links in the DB). AFAIK internal: was meant for local unrouted URLs like e.g. internal:/robots.txt

  • Thank you very much for the hint. It works. Bit i am still wondering why the method in question is not working. I will wait couple of days to check if anyone can provide any additional information on why it is not working. Or else I will mark your answer as accepted answer. Nov 12 at 16:17

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.