How can I display only My account link in top links in magento?

How can I display only My account link in top links in magento?

July 28, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How can I display only My account link in top links in magento?

As an experienced Magento developer, I often get asked about customizing the header links to display only certain elements, such as the “My Account” link. In this post, I’ll guide you through the process of achieving this.

Understanding the Magento Header Structure

The Magento header is controlled by XML layouts defined in your theme’s app/design/frontend/<your_package>/<your_theme>/layout folder. The default layout file for the header is page.xml.

In the <default> handle, you’ll find the following:

<block type="page/html_header" name="header">
    <action method="setTemplate"><template>page/html/header.phtml</template></action>
    <block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml" />
</block>

The catalog.topnav block is responsible for rendering the top navigation menu, which includes all the links.

To display only the “My Account” link in the header and hide everything else, you need to modify the catalog.topnav block. You have two options:

  1. Using a static block (CMS)

    This is the simplest approach but isn’t as flexible.

    • Create a new static block named “My Account Link” under CMS > Pages.

    • Add only this code: <li><a href="<?php echo $this->getUrl('customer/account/login') ?>">My Account</a></li>

    • In your theme’s XML layout file (page.xml), replace the catalog.topnav block with a reference to the static block:

      <reference name="header">
          <block type="cms/block" name="my_account_link">
              <action method="setBlockId"><block_id>my_account_link</block_id></action>
          </block>
      </reference>
      
    • Remove the original catalog.topnav block.

  2. Using a custom XML layout

    This approach provides more control but requires some programming knowledge.

    • Create a new file in your theme’s app/design/frontend/<your_package>/<your_theme>/layout/local.xml.

    • Add this code:

      <layout version="0.1.0">
          <default>
              <reference name="header">
                  <block type="core/text_list" name="my_account_link">
                      <action method="addLink" translate="label title"><label>My Account</label><title>My Account</title><link>customer/account/login</link></action>
                  </block>
              </reference>
          </default>
      </layout>
      
    • In your theme’s page.xml, remove the original catalog.topnav block.

Conclusion

As you can see, both approaches allow you to display only the “My Account” link in the header while hiding everything else. The choice between a static block and a custom XML layout depends on your specific requirements and comfort level with Magento’s programming structure.

Remember that these changes should be made in your theme’s folder (app/design/frontend/<your_package>/<your_theme>) to avoid losing them during updates. For more advanced customization options, consider checking out our guide on Magento Theme Development at Laravel Company.

If you have any further questions or need assistance with other Magento development tasks, feel free to reach out to us!

Catalog Themes Customers

Our network