How To Add Top Link In Magento 2

In this post, I will guide you on How To Add Top Link In Magento 2. Use the header of the website to deploy advertising campaigns, gratitude for the store’s customers.

The header of the website is the location that attracts a lot of attention, this is an ideal place to place important events, promotional campaigns, shopping, gratitude for your customers. Adding a link at the top of the page will make it easier for customers to reach it.

The difference between header and top link is:

  • The header is visible to both guests and logged in.
  • The top link is only visible to logged in customers.

Steps To Add Top Link In Magento 2

1. Create default.xml file in the following path:


2. And add the following code:

<?xml version="1.0"?>
<page xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
      <referenceBlock name="header.links">
        <block class="Magento\Framework\View\Element\Html\Link" name="top-link">
              <argument name="label" xsi:type="string" translate="true">Top Link Label </argument>
              <argument name="path" xsi:type="string" translate="true">url_path</argument>

You substitute the values below according to your need:

  • Top Link Label: The label of the top link you want to add to your store.
  • url_path: The URL path for the top link.

3. Then, run deploy static content, flush cache command and see the result:

php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

Follow us for the more helpful posts!

We hope this is a useful post for you.

You can read more useful posts like How To Change Order Increment ID Length In Magento 2.

Thank you for reading!

4.8 4 votes
Article Rating

Aaron LX

Aaron is a passionate writer, crazy about shopping, eCommerce and trends. Besides his outstanding research skills and a positive mind, Aaron eagerly shares his experience with the readers.

Leave a Reply or put your Question here

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x