7

I have inherited a theme from Magento's blank theme, now I need to remove the My Account and Wishlist links from the top.links block. To remove the links, I am using Magento_Theme module's default.xml layout file. Below is the xml that I have added to remove the links:

<body>
    <referenceBlock name="my-account-link" remove="true" />
    <referenceBlock name="register-link" remove="true" />
    <referenceBlock name="wish-list-link" remove="true" />
</body>

But it does not have any effect on frontend. Please tell me if I am missing something? or is it the right place I should place this xml?

I have checked the log files, there is no entry related to layout or top.links.

3 Answers 3

30

for me after adding referenceBlock then worked. Tested

   <referenceBlock name="top.links">
        <referenceBlock name="register-link" remove="true" />           <!--for Create Account Link-->
        <referenceBlock name="authorization-link" remove="true" />      <!--for Sign In Link  -->
        <referenceBlock name="wish-list-link" remove="true" />          <!--for WishList Link-->
        <referenceBlock name="my-account-link" remove="true" />         <!--for My Account Link-->

    </referenceBlock>

Here is Reference

1
  • How you can know what is the name of each block? you need to go to wishlist layout to figure it out or there is more easy solution to find it?
    – Goldy
    Sep 14, 2016 at 18:14
4

The login link wasnt remove from the above snippets for me so if anyone is having issues with it too. This snipped worked for me:

<referenceBlock name="top.links">
    <referenceBlock name="register-link" remove="true" />           
    <referenceBlock name="authorization-link" remove="true" />      
    <referenceBlock name="wish-list-link" remove="true" />          
    <referenceBlock name="authorization-link-login" remove="true"/> <!-- This was missing in the above answer, atleast for me -->         
</referenceBlock>
1
  • it worked but css and js file are still rendered . is there any option to remove it Nov 22, 2019 at 7:37
2

You can just add my-account-link and register-link inside your themes customer module default.xml file and remove from Magento_Theme default.xml file. Wihslist keep inside default.xml of Magento_Theme folder

app/design/frontend/Package/themename/Magento_Customer/layout/default.xml

XML look like:

 <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <body>
            <referenceBlock  name="my-account-link" remove="true"/>
            <referenceBlock  name="register-link" remove="true"/>
        </body>
    </page>

Remove var and check.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.