How to edit magento topmenu

How to edit magento topmenu

July 14, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to edit magento topmenu

Editing Magento Topmenu: A Guide for Developers

As a senior developer at Laravel Company, I often receive queries from fellow developers about customizing Magento’s top menu. The default topmenu.phtml file contains the basic structure of the navigation bar, but it doesn’t directly manage the ul and li elements that display the menu items.

The actual menu data is generated by a block called ‘catalog/navigation/toplinks’. This block uses the getChildHtml() method to retrieve child blocks, which are then rendered into the main template file.

Locating the Menu File

To find the file containing the ul and li elements, we need to look at the layout XML files that define the structure of the catalog navigation. The key file is located at:

app/design/frontend/<your_package>/<your_theme>/layout/catalog.xml

In this file, you’ll find the <reference> element for the ‘catalog_top_links’ block. It should look something like this:

<reference name="catalog.toplinks">
  <action method="addLink" ifconfig="topmenu/topmenu_enabled">
    <link>
      <label>Home</label>
      <url helper="customer/getHomeUrl"/>
    </link>
  </action>
</reference>

Each addLink action within this block corresponds to an item in the top menu. The <label> element is the text that appears in the menu, while the <url> element specifies the link’s destination.

Editing the Menu

To add a new menu item or modify an existing one:

  1. Open your catalog.xml file.
  2. Locate the ‘catalog.toplinks’ reference block.
  3. Add a new addLink action inside this block to create a new menu item, or update the existing actions to modify existing items.

For example, to add a “Contact Us” link to the top menu:

<reference name="catalog.toplinks">
  <action method="addLink" ifconfig="topmenu/topmenu_enabled">
    <link>
      <label>Home</label>
      <url helper="customer/getHomeUrl"/>
    </link>

    <!-- New menu item -->
    <block type="core/text_link" label="Contact Us" name="contact-link">
      <action method="setData"><key>text</key><value>Contact Us</value></action>
      <action method="setData"><key>href</key><value>{{store direct_url='contacts'}}}</value></action>
    </block>

  </action>
</reference>

In this example, we’re using the core/text_link block to create a new link. The setData actions specify the label and URL for the “Contact Us” menu item.

Conclusion

Editing Magento’s topmenu involves understanding how the catalog navigation works at a structural level. By locating the correct layout XML file (catalog.xml) and modifying the ‘catalog.toplinks’ block, you can add, remove, or update items in the top navigation bar.

Remember to clear your cache after making changes to see the updates take effect. For more advanced customizations, consider using the Magento 2 Luma theme as a starting point or consulting with an expert at Laravel Company for professional assistance.

Don’t forget that good documentation and code organization are key to maintaining a healthy e-commerce project. Keep reading our blog for more tips on Magento development best practices!

Catalog Themes Configuration Customers

Our network