In this post I am going to explain how to add custom links in footer in Magento 2.
Here, I am using my custom module – Ht_Mymodule
First you need to add default.xml file in your extension and add below code in it.
File Path: app/code/Ht/Mymodule/view/frontend/layout/default.xml
<?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" name="custom-link">
<arguments>
<argument name="label" xsi:type="string">About Us</argument>
<argument name="path" xsi:type="string">about-us</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>Clear the cache and cache for the result.

Now if you want to add links from template file then add below code in default.xml
<referenceBlock name="footer_links"> <block class="Magento\Framework\View\Element\Html\Link" name="custom-link-template" template="Ht_Mymodule::footer-links.phtml" after="-" /> </referenceBlock>
Next to that, create footer-links.phtml template file.
File Path: app/code/Ht/Mymodule/view/frontend/templates/footer-links.phtml
<li class="nav item">
<a href="#">
<?php echo __('About Us') ?>
</a>
</li>Now, Clear the cache and cache for the result.
Write an article about ecommerce that help people to grow their ecommerce business. You’ll find best ecommerce guide, news, tips & more!


Leave a Reply