15

I am searching header.links block to remove one link and add some links but I am not getting where to make changes. Suggest me some solution

2
  • In this same custom links, how can I add the custom class? Apr 29 '19 at 13:20
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review
    – fmsthird
    Apr 29 '19 at 13:43
23

I Hope this is useful for you,

if you want to remove top.links

Add default.xml file in this path

app/design/frontend/vendor/theme/Magento_Theme/layout/default.xml

        <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
            <body>

                    <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-->

            </body>
        </page>

if you want to add Custom top links:

go to app/design/frontend/vendor/theme/Magento_Theme/layout/default.xml

        <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
            <body>
            <referenceBlock name="header.links">
                <block class="Magento\Framework\View\Element\Html\Link" name="custom-link">
                <arguments>
                    <argument name="label" xsi:type="string" translate="true">custom link</argument>
                    <argument name="path" xsi:type="string" translate="true">customlink</argument>
                </arguments>
                </block>
            </referenceBlock>

            </body>
        </page>
2
  • thanks for your answer how to add custom links and change the label of link
    – zest
    Sep 28 '16 at 5:05
  • How to add some design for the custom link which added in the header? @Rajkumar .E
    – zus
    Dec 11 '20 at 9:31
9

You can add and remove top links by add this line in your in Magento_Theme/layout/default.xml

    <referenceBlock name="header.links">
    <block class="Magento\Framework\View\Element\Html\Link" name="new.link" after="register-link">
        <arguments>
            <argument name="label" xsi:type="string" translate="false">New Link</argument>
            <argument name="path" xsi:type="string" translate="false">newlink</argument>
        </arguments>
    </block>

    <!-- here you can remove whatever link you feel unwanted -->
    <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>
2
  • 1
    How can I remove compare link in header.links
    – Omer
    Jun 5 '17 at 9:36
  • i have created custom links in header, how to move into after logo @Bilal Usean
    – zus
    Dec 11 '20 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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