Editing Magento’s Top Links (The Better Way)

You might need to read the post about using a local.xml file before this post makes much sense.

As a Magento development agency, we offer all our clients a completely customized design from scratch, which means changing anything – including those annoying defaulted top links.  This post will show you how to edit your top links (without editing core layout files which may change when you update Magento) by utilizing a local.xml file. You can even add your own custom links without touching any template files! [NOTE: This specific example assumes you are using the blank theme. Layout handles may differ from theme to theme.]

ADDITION: Check out the blog post about editing Magento’s footer links

In local.xml:

If you absolutely cannot find a way to customize your top links using these methods, you can edit the /template/page/template/links.phtml

Posted on February 24, 2010

Posted by Kevin Kirchner


  1. Thanks for this article. It was very helpful. I ended up removing the cart and checkout links, added the cart link back, and then created a custom link to replace the checkout link and have it pointing to the cart page. Turned out to be a nice quick fix to make sure customers end up on the cart page to see if any items are on backorder, and so they see where they are supposed to enter any discount codes. Modifying the template file for this wouldn’t have been quite as simple I expect.

  2. I want remove into onepage checkout, I’ve tried several ways but I can not.

  3. Why do you feel that adding a link via layout XML is better than adding it a .phtml file? Given that both can be done in a way that isn’t overwritten on upgrade, I’d prefer to edit the .phtml file, since its raw HTML & PHP, which is better documented than Magento’s proprietary layout XML (which is not only not documented well, but changes from version to version). Why do you recommend editing the layout XML given these issues?

    • Because that’s how Magento does it for the most part, I like to try and stick to the conventions set out by the application whether I agree with it or not. Actually the Magento layout XML is ok once you get used to it. It’s easier to maintain 1 local.xml file rather than have loads of old .phtml and static blocks lying around.

  4. Go ahead and add your link, with the default layout handle. Then remove it just on the home page using the home page’s layout handle. The layout handle for the home page is always “cms_index_index”.

  5. I’ve been trying to figure out how to add a non-CMS page link to the Log in | My Cart | My Account, etc. menu. I see here a lot of help adding links WITHIN the CMS, but I want to add a HOME link to my “outside” home page, not the Magento CMS home page. Are there any suggestions for that?

    I would also like to do the same for the page logo, but that’s another topic discussion.



  6. Hi, Also I found a way to remove the “add to comparison” link/button in product page. Hope this is also to be included in your tips.

    Here the mentioned:

  7. Oops, seems like there’s a issue with formatting options. I was talking about: reference name=”root”.

  8. Why the use of ? Is that really necessary?

  9. Hi all. I know less than zero about all this coding stuff. I (my web designer) is having an issue with spacing in the header links. The links are “Login | My Account | My Cart | Checkout”. The spacing between the dashes ( | ) and links are not consistant across the web browsers. They are not evenly spaced on any browsers and look outright wrong on others (Safari, Mac OS, IE W7 & Mac). Do you guys and gals have any information I can pass along to my web designer?


  10. Thanks a lot for this helpful and technically accurate article. Great to see you using local.xm unlike so many of the attempts that are out there that hack away at core files. Works nicely for me in 1.6.

  11. My usual ways to go out this problem is that:
    add some code in page.xml as following:

    and then in 3columns.xml

    < ?php echo $this->getChildHtml(‘upheader’) ?>

    That’s work well for me!

  12. Disable it from the SYSTEM-CONFIGURATIONS-ADVANCE-Mage_Wishlist

  13. Hello, thanks for the help with this. :)
    I have a question about other links, not top links…

    I need the wishlist to be usable for logged in users only.
    so the link ‘add to wishlist’ on the products page should just be visible when a customer is logged in.

    Any ideas?


  14. Thanks for you share buddy! I have a question, I can’t add a new class attribute with your code. A id or something else worked perfectly. Would you like to tell where is wrong?

  15. Hello everybody
    I have got 3 blogs and 2 websites.Can i have google adsense ads in my all of these blogs and websites ? Whether i have to apply for different google adsense accounts or a single account will work for all these websites and blogs.

    Thank You.

  16. Greate resource. Thanks very much 😀

  17. thanks for the information. It is actually very helpful to the ones who are using magento for their online stores.

  18. er code messed up…

    HowTo Remove WishlistLink:

    HowTo Set CSS ID in ul tag:




  19. third try:

    er code messed up…

    HowTo Remove WishlistLink:

    HowTo Set CSS ID in ul tag:

    <reference name="top.links">
    <action method="setData"><key>name</key><value>main_nav</value></action>

  20. HowTo Remove WishlistLink:


    HowTo Set CSS ID in ul tag:


  21. Er, the code didn’t show up, how do I post code 😛

  22. Andy, I’m running as well and this method (that I found another forum) for knocking out the wishlist worked for me:

    Comment out the following from frontend/default/yourtheme/layout/wishlist.xml. Just make sure your cache is disabled and such.



    Really wish there was a less-complicated way to do all this…

  23. Wishlist removal code does not work anymore with 1.5, I just deactivate it in control panel ´cause I won´t need it.

  24. @Jameson Proctor

    I figured it out <prepare>true</prepare> needs to be set to <prepare /> not <prepare>false</prepare>. For some reason, prepare to false is no different than setting it to true.

  25. This an excellent tutorial. Thank you. I am trying to use this to add a link to the top.links that points to another domain. So far I have had no luck. No matter what I do, Magento just appends the link to the end of my base url.

    Any help would be greatly appreciated.

  26. running and the wish code still breaks the site. any ideas? what am i doing wrong?

    Also trying to hard code adding a navigation link at top.phml. when I edited the code the main-container area is broke. Any help you can give is greatly appreciated.


  27. Heya kkircher,

    (firstly, apologies for the miss-post above, please delete!)

    Is there any additional magic to making this work with the category links instead of top.links ?

    I am trying the below in catalog.xml to start with prior to trying to moving it into local once its working (local I assume has an unset issue as it causes an exception!) ?

    <reference name=””>
    <block type=”catalog/navigation” name=”catalog.topnav” template=”catalog/navigation/top.phtml”>
    <action method=”addLink” translate=”label title”>
    <label>Home Page</label>
    <url helper=”core/url/getHomeUrl”/>
    <title>Home Page</title>

    I assumed the above would work (, blank theme), but in effect nothing gets output. Suggestions welcome!

  28. great , it help me ,too. TKS. ( in ver.1.4 )

  29. Home



  30. Great reading!

    Makes magento to customize way simpler! I’m trying to add front page to my navigation, but it just dont work. I did managed to add it to top.links. Here is my code, magento






  31. Such a good system is the old Magento, but for the fact that there is no decent way to manage those frickin menus! menu items should be pulled from the database as proper menu items, that are linked to “menus” which are also stored in the database, then, only once that is working OK should they add in the ability to override (via XML) full menus, ir single menu items. I think that is a good balance between “developer” friendly, and “commercial self preservation”. I.e. only savvy developers can work it out, apart from the people that make money at Magento – I believe this is their business model in the big picture, I dont blame them either :)

  32. Whoa! Very deep! I’ll give this implementation a try and let you know how it goes. Thank you very much for the response and idea!

  33. @Jef – Very interesting question. I dug in to catalog.xml and catalog/product/compare/sidebar.phtml to see what I could find.

    The button that opens the comparing pop-up box uses a php method to dynamically create the pop-up box. So you can probably use your own phtml file for it.

    In local.xml:

    Now create the comparelink.phtml file and modify the code from catalog/product/compare/sidebar.phtml:

    I’ve not tested this but it should work in theory… good luck!

  34. Thanks for these great alternatives!!

    I have a new question for you. I’m using a custom theme and a one column format throughout the entire site. My problem is that when users wish to click on “Add to Compare” for several products, the corresponding link to “Compare Products” is not available anywhere. I wanted that link to automatically be available in the top links discussed above. In the 2 or 3 column format, the “Compare Products” list and link is in the sidebar for immediate access.
    Any thoughts on this dilemma???

    Thanks again!!

  35. Thanks, I’ve been struggling with this for a while! Top menu links now edited!

  36. Bravo! The top links were doing my head in… it’s nice to have them in one place! Thanks for the info.

  37. HI I WANT TO remove totally menu and add new html as topnew.phtml i have done like this in local.xml

    its removing top.phtml but i cant add topnew.pthml Please help me…Can anyone??

    Waiting for reply

  38. HI I WANT TO remove totally menu and add new html as topnew.phtml i have done like this in local.xml

    its removing top.phtml but i cant add topnew.pthml Please help me…

    Waiting for reply

  39. Thanks, couldn’t quite get those darn links removed with the other solutions. This one finally seemed to work.

  40. Was an expression of thanks really useful.

  41. Hi,
    pay attention when you specify a “false” value: leave the tag empty (ie: ) or use 0 as false (ie: 0) otherwise you won’t get what you expect.

    Thank you for your help.
    Sincerely, Alessandro

  42. Hi,
    pay attention when you specify a “false” value: leave the tag empty (ie: <prepare/>) or use 0 as false (ie: <prepare>0</prepare>) otherwise you won’t get what you expect.

    Thank you for your help.
    Sincerely, Alessandro

  43. @Yasmine – The code goes in a local.xml file. To learn about where to put the local.xml file, take a look at our blog post here.


  44. I wanna know where i should place the code showing above …Thanks for help

  45. @ehansen,
    Thanks for the tip. I’ll give that a shot and see how it goes.

  46. @Brandon – The simplest solution for making changes like that is to use the Translate Inline tool. You can turn on this tool on the System > Configuration > Developer page.

  47. New to Magento development here. Is there an easy way to edit the text of My WishList and My Account this way? I want to edit My Wishlist to simply say “Wishlist”. I would like to edit My Account to say “Sign In” (only when a user isn’t currently signed in).

  48. @kkirchner,

    I knew abou the easy way, but I was just wondering if it could be done the other way round 😛 Thanks for your time!

  49. Another option – you can copy the removeLinkByUrl method in app/code/core/Mage/Page/Block/Template/Links.php and paste it in a custom module that extends the Mage_Customer_Block_Account_Navigation class in app/code/core/Mage/Customer/Block/Account/Navigation.php. If you’re going to go that far, you might as well add a custom helper to get the tag and review path with your baseUrl. Check out this comment.

  50. @Vier,

    Both Tags and Reviews are Magento core modules which you can disable in the admin. Once you disable them, the links will no longer show up on your customer account list of links.

    Under System > Configuration > Advanced (bottom of left sidebar) > Disable Module Output. Select Disabled for Mage_Review and Mage_Tag.

  51. Sorry for the amount of spam, the code and pre tags didn’t work for me :(

    Hi, I’m trying to edit the customer_account_navigation block to remove the My Tags and My Product Reviews links but I can’t make it. This is what I’ve tried so far in local.xml:

    <reference name="customer_account_navigation">
    <remove name="tags"/>


    <action method="removeItem"><name>tags</name><path>tag/customer/</path><label>My Tags</label></action>
    <action method="unsetChild"><name>tags</name></action>
    <action method="removeLinkByUrl" module="tag"><url></url></action&gt;
    <action method="removeLinkByPath" module="tag"><name>tags</name><path>tag/customer/</path></action>

    Do you have any ideas? Thanks for the help!

  52. Very much apprecaited – very helpful!

  53. @James Wyson – Thank you for catching that error. I’ve properly closed the beforeText tag.

    Also, the log in link only shows when the user is logged out. And conversely, the log out link only shows when the user is logged in. So you have to wrap the remove login link in the customer_logged_out tag and the remove logout link in the customer_logged_in tag. The code shown above for local.xml is correct.

  54. @James Wyson – Can you wrap your code examples in pre tags? See the example code above the comment box for details.

  55. There is an error in the local.xml posted. The beforeText tag was not properly closed.

    Kindly change to:

  56. Also, kindly change the local.xml posted above to remove the log out url when the customer is logged out and to remove the log in url when the customer is logged in.

  57. @Jerry – I tested the logged in and logged out on 1.4 with the blank theme and it worked for me… double check and make sure they’re after the </default> tag.

  58. Wow, Russ! That looks great. I’m definitely going to check this out – that could be super helpful!

  59. Thanks kkirchner,

    I didn’t want to hard-code links as we run about a dozen sites, But I did a little digging myself and came up with this code for local.xml which uses a url helper to generate the correct URL for the homepage of the current site.

  60. Hi

    Using 1.4, the customer logged on/out code doesn’t work.

    Ay ideas gratefully received.



  61. Thanks for this, very helpful!

  62. Thanks for the great manual!
    My problem is with multilanguage shops.
    Can you say me how to translate, for example, About us to “&Uml;ber uns”.

  63. I am trying to do the same thing, however I cant seem to get it to work atall without crashing. I want to add 2 links to the top link of the site that direct to a CMS page. What files do I modify?

    thanks in advance :)

  64. Wow both this is awesome! I have been fighting magento for going on a year. hopefully with help from this we will be able to streamline our magento development

  65. @Russ – thanks for that question.

    I dug into the app/code/core/Mage/Page/Block/Template/Links.php file. You can use the full url in your ‘url’ tag or add a param to the addLink method. The latter is shown here – in your local.xml:

  66. Thanks for the info on removing links; I’m trying to add a link to a cms page and to the homepage using the method above, but the links generated are not parsed in any way eg. home just passes “home” as the complete anchor href element href=”home” which is incorrect.

    The same is true for my CMS page, which breaks these links from pages where the base url is wrong, like the customer account page; the links suddenly become href=”customer/account/home” and “customer/account/customer-service” for example.

    Any thoughts on how to make Magento parse the page names and insert fully qualified URI’s as it does for ‘helper’ links like the customer login & basket links?

  67. Thank you, this is extremely helpfull

  68. Thanks bluescrubbie,

    It looks like in 1.4 they changed the wishlist.xml – just replace:


    Because of the “remove” global effect, if you want to re-add the wishlist link somewhere else, you need to create a custom block. I just copy it from wishlist.xml, change the name attribute of the block, and place it in my local.xml file.

  69. Sadly, this code chokes on wishlist for me under Any ideas?
    a:5:{i:0;s:278:”Warning: call_user_func_array() []: First argument is expected to be a valid callback, ‘Mage_Wishlist_Helper_Data::’ was given in \app\code\core\Mage\Core\Model\Layout.php on line 326″;i:1;s:1934:”#0 \app\code\core\Mage\Core\Model\Layout.php(326): mageCoreErrorHandler(2, ‘call_user_func_…’, ‘C:\web\root\…’, 326, Array)

  70. thanks! BTW, there’s a missing close bracket on

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">