Skip to main content
1 of 3

How to move existing links and add new custom links in top header?

I already check many answers regarding the move header.links to header-wrapper its working but the problem is that it also move my custom links to header content.

I am trying to create a new container which has a parent header.links, but its not working.

here is my default.xml

    <referenceContainer name="header.links">
        <container name="custom-content" as="custom-content" label="Page Custom Content" htmlTag="div" htmlClass="custom-content">
        </container>
    </referenceContainer>

    <move element="custom-content" destination="header-wrapper" />

    <referenceBlock name="custom-content">
        <!-- Contact us Link -->
        <block class="Magento\Framework\View\Element\Html\Link" name="contactus.link" after="register-link">
            <arguments>
                <argument name="label" xsi:type="string" translate="false">Contact Us</argument>
                <argument name="path" xsi:type="string" translate="false">contact-us</argument>
            </arguments>
        </block>
        <!-- CMS Page Link Link -->
        <block class="Magento\Framework\View\Element\Html\Link" name="aboutus.link" after="contactus.link">
            <arguments>
                <argument name="label" xsi:type="string" translate="false">About Us</argument>
                <argument name="path" xsi:type="string" translate="false">about-us</argument>
            </arguments>
        </block>

        <!-- CMS Page Link Link -->
        <block class="Magento\Framework\View\Element\Html\Link" name="customerservice.link" after="customerservice.link">
            <arguments>
                <argument name="label" xsi:type="string" translate="false">Customer Service</argument>
                <argument name="path" xsi:type="string" translate="false">customer-service</argument>
            </arguments>
        </block>
    </referenceBlock>

First I create new container custom-content then I move existing links like Sign in, Create an account link & Greeting message to header-wrapper and then define my custom link into my custom container, but its not working.

if I remove custom container then move is working fine.