4

When creating a link to a menu item inside an article or module, my first thought is to use the menu item alias and make the link like this:

<a href="/contact">Contact us</a>

The problem is that this link might break for a series of reasons:

  • .htaccess is not enabled (requires the link to include "index.php")
  • The alias changes (e.g. to "contact-us")
  • The menu item is moved to a different level or to another parent (e.g. to "/about/contact")
  • Joomla is moved to a subfolder (e.g "/joomla/contact")

How can I safely link to a menu item?

1 Answer 1

3

The solution is quite simple:

Instead of using the alias, create a link with the menu item ID:

<a href="index.php?Itemid=XX">Contact us</a>

where XX is the ID of your menu item. The ID can be found in the menu item manager:

Menu Item ID location

The link will automatically be converted to the correct URL, regardless of the menu item alias, location etc.

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.