Speed up your Magento store with Managed hosting. Use promo: MGT25 Avail Now
Magento 2 Tutorials

How to Add Custom Header Link in Magento 2

add top link in magento 2

Your website’s header is perhaps the best place to display important links and pages. There are a few links in the header section of the store by default in Magento 2. I have also seen queries asking how to add more links to the header section in Magento 2.

So today I’m going to teach you how to add header link in Magento 2. I will implement it using a custom module!

Configuration of Module

To configure the module, create module.xml file in app/code/Magenticians/Mymodule/etc and paste the following code in it:

Registration of Module

To register the module, create registration.php file in app/code/Magenticians/Mymodule and paste the following code in it:

Create Layout File

Create default.xml file in app/code/Magenticians/Mymodule/view/frontend/layout and paste the following code in it:

In the code above, I have added the contact us page link. You can change it according to your need.

Create Block File

Create Link.php file in app/code/Magenticians/Mymodule/Block and paste the following code in it:

Run CLI Commands

Go to the root directory of your store by connecting it with SSH and then run these commands:

Open your store and you will see the new link Contact Us:

Top link in Magento 2

Final Words

To increase the chances of more sales, make sure all the useful pages/links of your store are visible. After following this guide, I hope you’ll be able to add a top link in Magento 2. Still facing issues in its implementation? Just drop your query in the comment box and I will get back to you!

Subscribe Newsletter

Subscribe to get latest Magento news

Experience Faster
Managed Magento Hosting