The header and footer are key elements of a website. Typically, they contain links to important pages on your site that potential customers will often want to visit before making a purchase or enquiry.

Add Custom Header and Footer Links

The header is the first thing that people will see when they land on your site. It sets the tone for the whole site. You need to include enough information in the header to encourage customers to explore your site further.

The footer of a website is just as important as the header, as it is the last chance for you to grab a customer’s attention and encourage them to complete an action, such as making a purchase or requesting information.

By following the steps mentioned below you can create your custom header and footer links and make your site more attractive and clear.

How to Add Custom Header Links in Magento 2?

Step 1:

Create a custom module based on Magento 2 structure in the folder app/code.

Step 2:

Create module.xml file in the below path to define your Magento 2 extension.

Magento 2 root directory/app/code/Dckap/Newlink/etc/module.xml

 Step 3:

Create routes.xml in the below path for your custom link.
Magento 2 root directory/app/Dckap/Newlink/etc/frontend/routes.xml

Step 4:

Create layout file in the below path for a custom header.
Magento2 root directory/app/Dckap/Newlink/view/frontend/layout/header.xml

 Step 5:

Create block file that is referred in the layout file in the below path.

Magento2 root directory/app/Dckap/Newlink/Block/Header.php

For third party URLs follow the above code.

Step 6:

Create template file that is referred to the block file in the below path.

Magento2 root directory/app/Dckap/Newlink/frontend/templates/link.phtml

Step 7:

After completing the above steps run the below Magento2 upgrade command in the command prompt:

After running the above command, clear all the Magento cache and check whether the extension is installed successfully in the Magento 2 admin side.

p1-tiny

p2-tiny

How to Add Custom Footer Links in Magento 2?

Step 1:

Now to add custom footer link follow the above first 3 steps and replace the layout file with the below code:

Magento2 root directory/app/Dckap/Newlink/view/frontend/layout/footer.xml

There are 2 ways of getting the argument values:
1.By using block file. (used for header link)
2.By specifying argument values in the layout file.(used for footer link)

Now follow the above step(step 7).

Check the browser to see your custom header and footer links.

p3-tiny

p4-tiny

Hope this blog helped you to add custom header and footer links in Magento2.

Be the first to Know

Subscribe to our blog to get the latest articles directly to your inbox.

READY TO DRIVE SALES?

Ready to drive online revenue

Get In Touch

17 thoughts on “How to Add Custom Header and Footer Links in Magento 2?

    1. Hi @Jayaprakahs its default functionality or for security reason no ecommerce CMS displays both header and footer links on checkout Page

  1. I’m curious to uncover out what weblog system youre employing? Im experiencing some small security problems with my latest weblog and Id like to locate something a lot more safeguarded. Do you have any recommendations? cbcdgfdkddcbdbbe

    1. Hi,

      Here is the reply…

      1.Overwrite the Magento_Theme module in your theme

      2.Goto view->frontend->layout->default.xml

      3.Add the below line of code under

      4.Clear the cache

      5.Refresh the frontend

      Let us know if this is useful
      subscribe to our blogs.
      Thanks.

    1. Hi,

      Here is the reply…

      1.Overwrite the Magento_Theme module in your theme

      2.Goto view->frontend->layout->default.xml

      3.Add the below line of code under

      4.Clear the cache

      5.Refresh the frontend

      Let us know if this is useful
      subscribe to our blogs.
      Thanks.

  2. Hi,
    i tried to add custom links to header, in magento 2.1.8 but couldn’t see in any link in header,but its working in footer very perfect..I followed according to your tutorial but can’t make change in header.Please help me..

  3. Hi Gayathri,

    I appreciate your work on producing this article, i was looking for help in creating layout with some integration and got helped by your article in header and footer, but for Magento 2 Layouts, Blocks, And Templates i found this, After creating the directory structure, we will now declare and register our theme by adding theme.xml and registration.php so that Magento 2 registers the theme’s existence.

    1. Hi Alex,

      Thanks for sharing this.
      Good to know you found what you needed.
      Please keep reading our blogs and share your insights, comments and feedbacks.

  4. Nice Post. Thanks for Sharing. Also, check out this blog to learn simple and effective method to Include Custom Header Links in Magento 2. Click: goo.gl/rpHAQ6

Leave a Reply

Your email address will not be published. Required fields are marked *