Adding Your Own Link to the Magento 2 Header Links

Adding Your Own Link to the Magento 2 Header Links

The small links in the Magento 2 header, such as My Account and Sign In, come from the top.links block. Adding your own is a layout change.

Layout XML

Add this to default.xml in your theme:

<referenceBlock name="top.links">
<block class="Magento\Framework\View\Element\Html\Link\Current" name="contact-us">
<arguments>
<argument name="label" xsi:type="string">Contact Us</argument>
<argument name="path" xsi:type="string">contact-us</argument>
</arguments>
</block>
</referenceBlock>

Use sortOrder to control position, then flush the cache.

Want this done for you? Find out more about our Magento development service.

Keep reading

Related articles

All articles

Need a hand?

Stuck on something similar?
We can fix it with you.

Send us the problem. A senior developer reads every message and replies within one working day.