My active class name is not working for menu items that redirect to a node using URL aliases

For example, if I have a node node/10 and its alias URL is movie/avengers, I'm not able to see the active class for the menu item if the link is provided as an alias URL (movie/avengers)

The active class is available and it toggles between the links on clicks if I'm providing the link as node/[id] instead of URL aliases for the menu item.

So please advise how can I use the active classes for menu items even if I'm providing URL aliases instead node/[id]

1 Answer 1


The menu system is based on system paths like node/10. They are transformed to path aliases automatically when menu links are rendered. If you use the menu link option on the node edit page the menu link is created correctly. If you add a menu link by hand and use the path alias instead of the system path you break the relationship between node and menu link. This is not a good idea for maintaining node menu links and it doesn't work for multilingual sites.

The active class could then be an additional minor issue explained already because of the broken relationship. Although in a simple test with a menu link stored as link_uri = internal:/path/alias I couldn't reproduce the issue. Drupal was still able to connect the correct system path for the active link, visible on the web page by toggling the highlighted link and also in the HTML source by the data-drupal-link-system-path link attribute pointing at node/[id].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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