How to Add and edit Footer Links in Magento 2
Website footers may not be the place with great design or content, but its the place where the visitors look for the details. And the Magento 2 store owners cannot afford to miss any vital details or links in the footer.
However, the default Magento 2 footer is not up to the mark. The store owners have to modify the footer in order to deliver all the required information and the links.
Fortunately, Magento 2 is a flexible CMS that allows editing the footer.
The programmatic method to add and edit footer links in Magento 2 makes it easy for the admin to customize the footer.
Method to Add and Edit Footer Links in Magento 2:
- Create module.xml file at app/code/Vendor/Extension/etc/ directory
1234<?xml version="1.0"?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"><module name="Vendor_Extension" setup_version="1.0.0"></module></config> - Create registration.php file at app/code/Vendor/Extension directory
123456<?php\Magento\Framework\Component\ComponentRegistrar::register(\Magento\Framework\Component\ComponentRegistrar::MODULE,'Vendor_Extension',__DIR__);
To remove the Privacy and Cookie Policy link from the footer:
Create default.xml file at app/code/Vendor/Extension/view/frontend/layout directory
1 2 3 4 5 6 |
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="privacy-policy-link" remove="true"/> </body> </page> |
To add new footer link:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="footer_links"> <block class="Magento\Framework\View\Element\Html\Link\Current" name="custom-footer-link"> <arguments> <argument name="label" xsi:type="string">Customer LInk</argument> <argument name="path" xsi:type="string">custom/extension/index/</argument> </arguments> </block> </referenceBlock> </body> </page> |
That’s it.
Please use the Comments section below if you have any doubts on the topic and I’d be happy to help. You may also love to read our another blog post on how to remove default footer links in Magento 2.
Feel free to share the solution with the fellow developers via social media.
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
4 Comments
Hi, I tried this out, following the steps 1, 2 and 3 exactly but privacy link still appears. I’m using exact file names and exact directory structure as above, I also flushed Magento Cache.
I’m using Magento 2.3.5 and Luma theme.
Any ideas?
Regards
Janak
Hello Janak,
We have cross-verified the solution and it works perfectly fine for us.
It seems there’s some other mistake which is going unnoticed. Please make sure of the same.
Thank you.
Hi, thanks you for your reply,
Thanks for your help, I’m new to Magento development, I put in my actual Vendor and Extension names in the directory paths and in the files and it all worked. A great post.
Regards
Janak
Hello Janak. thank you for the appreciation.