Add link in Magento menu

Add link in Magento menu

September 8, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Add link in Magento menu

Solving Magento Menu Link Issues: A Comprehensive Guide

Are you struggling to manually add links to your Magento menu? You’re not alone! In this post, we’ll walk through the process step-by-step, ensuring you gain a solid understanding of how to customize your navigation.

Understanding Magento’s Navigation Structure

Magento uses a hierarchical structure for its menus. The core files are located in app/code/core/Mage/Cms/Block/Page.php, but direct modification is not recommended as it may be overwritten during updates.

Instead, you should work within the theme folders to maintain your changes across updates. The key file for top-level menu links is typically found at app/design/frontend/{package}/{theme}/template/page/html/toplink.phtml.

Editing Your Theme’s Menu File

Step 1: Locate the Correct File

Navigate to your theme folder using a FTP client or the Magento file manager. Look for toplink.phtml within the page/html directory.

Tip: If you’re unsure about your current theme path, run this command in your terminal:

bin/magento setup:info:theme

Open toplink.phtml and look for a section that starts with <ul class="menu">. Within the <li> tags, add your custom link like this:

<li>
    <a href="{{store direct_url 'custom-route'}}">Your Custom Link</a>
</li>

Replace 'custom-route' with the name of the route you want to link to.

Step 3: Flush Magento’s Configuration

After making changes, flush your configuration cache by running:

bin/magento cache:flush

Troubleshooting Common Issues

Issue 1: Changes Aren’t Being Displayed

If your changes aren’t reflected on the frontend, ensure you’ve cleared both browser and Magento caches. You can do this via System > Cache Management in the admin panel.

Double-check that the route specified matches an existing one in your routes.xml or module-route.xml files. Use the command bin/magento setup:info:routes to see a list of available routes.

Best Practices for Menu Management

  1. Avoid hard-coding URLs directly into templates. Instead, use the {{store direct_url}} helper method.
  2. Keep your menu management within your theme folders for easier maintenance and updates.
  3. Consider using Magento’s built-in menu configuration tools in the admin panel (Content > CMS > Pages) if possible.

Conclusion

Adding links to your Magento menu should now be straightforward! Remember to keep your work within the theme folders, clear caches when needed, and double-check route names for accuracy.

For more advanced navigation customization, consider exploring third-party extensions or Magento’s menu configuration XML files. If you’re looking to level up your Magento development skills, don’t miss our comprehensive guides at Laravel Company.

Happy coding! Let us know if this guide helped resolve your menu woes.

Themes Configuration Errors CLI

Our network