How to Add a Custom Header Link in Magento 2

How to Add a Custom Header Link in Magento 2

Liam Firth

A New Era in eCommerce with Magento 2

Magento 2 is the latest incarnation of the leading eCommerce platform.  Magento software is now used by over 200,000 retailers across the globe. In fact, recent figures suggest that 1 in 4 businesses now use the Magento platform for their online business.  It’s easy to see why so many online businesses choose to use Magento 2.  This eCommerce platform offers a plethora of flexible tools that easily cover all of your advanced marketing needs.  Also, with this latest incarnation, you can control most aspects of the look, content and functionality of your site.

One of the best thing about Magento 2 is that it offers significantly improves scalability.  With the Community Edition, you can expect full page caching.  This enables faster speeds on your site.  With Magento 2, the platform has been stripped down and completely rebuilt to offer a more streamlined user experience that is quicker, safer and easier to use.

This new Magento platform also boasts additional tech in the form of a re-envisioned CSS pre-processor and HTML5 functionality.

Header Space on Your Magento 2 Store

The header space on your website is often the best place to display important pages and links.  This makes it a key element of any website.  Typically, your header space will include links to the most important pages on your site.  The header is typically the first thing anyone will see when they land on your site.  This means that your header space will often set the tone for the whole site.  You need to make sure that you include all the important information about your business in the header.  This will hopefully encourage customers to explore your Magento site further.

With Magento 2, you will already have access to a few links in the header section of your store by default.  In this article, we’ll talk you through how you can add header links in your Magento 2 store using a special custom module.

Configuring Your Module

If you would like to configure you’re the module, you’ll first need to create a module.xml file.  This file will need to be created in the Mymodule section of your store.  Once you have inputted your code, you’ll then need to register the custom module.  To do this, you’ll need to create a new registration.php file.  Once you have completed this step, you can then create a layout file.  Here, you’ll be able to add in a ‘contact us’ page link if you want.

After you create a layout file, you’ll need to create your block file.  You will then be able to run CLI commands.  T do this, you’ll have to visit the root directory of your Magento 2 store.  This is done by connecting your store with SSH.

It’s vital that your header space is used effectively.  To increase the chances of more sales, make sure that you include all of the useful links and pages of your store in the header space.

Already added a customer header to your Magento 2 store?  Let us know what you think should be included in a header space in the comments below.

Liam Firth

Author Liam Firth

Liam is a Technical Lead with eight-years’ experience in Magento and WordPress development, as well as engineering AWS and DevOps. He likes sourcing new and shiny tech solutions for real-world problems. He is a Magento Professional Certified Developer.

More posts by Liam Firth