Magento 2 Tutorials

Remove and Add Links in Magento 2 Footer

edit footer links in Magento 2

Footer is an important section of any ecommerce store. It is the last section of the store pages, and thus the last chance to convince the visitors to stay on the store and buy more.

I have seen queries on several Magento forums about how to edit links and add new links in the footer of Magento 2 stores. So today, I am going to teach you how to remove links and add new links in the footer of Magento 2 stores.

As always, when customizing Magento 2 stores, it is highly recommended that you create a custom module to ensure that the core files remain untouched.

Steps to Follow

Create a Custom Module

Create module.xml in app/code/Magenticians/Mymodule/etc and paste the following code in it:

<?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="Magenticians_Mymodule" setup_version="1.0.1"></module>
</config>

Create registration.php in app/code/Magenticians/Mymodule and paste the following code in it:

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Magenticians_Mymodule',
    __DIR__
);

Remove Link(s) and Add New Link(s) to the Magento 2 Footer

Suppose you wish to remove the Privacy Policy link and want to add Create an Account link in Magento footer.

Create default.xml file in app/code/Magenticians/Mymodule/view/frontend/layout.

To remove Privacy Policy link from Magento 2 footer, you need to add the following code in the  layout file:

<referenceBlock name="privacy-policy-link" remove="true"/>

Here are some link blocks you could easily remove:

  • Privacy and Cookie Policy: privacy-policy-link
  • Search Terms: search-term-popular-link
  • Contact Us: contact-us-link
  • Advanced Search: catalog-search-advanced-link
  • Orders and Returns: sales-guest-form-link

To add Create an Account link in Magento 2 footer, you need to add the following code in layout file:

<referenceBlock name="footer_links">
   <block class="Magento\Framework\View\Element\Html\Link\Current" name="custom-footer-link">
     <arguments>
       <argument name="label" xsi:type="string">Create Account</argument>
       <argument name="path" xsi:type="string">customer/account/create/</argument>
      </arguments>
   </block>
</referenceBlock>

In the code above, I have added the Create an Account link in Magento 2 footer according to the scenario.

The final default.xml file will look like this:

<?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"/>
       <referenceBlock name="footer_links">
         <block class="Magento\Framework\View\Element\Html\Link\Current" name="custom-footer-link">
             <arguments>
                 <argument name="label" xsi:type="string">Create Account</argument>
                 <argument name="path" xsi:type="string">customer/account/create/</argument>
             </arguments>
         </block>
     </referenceBlock>
</body>
</page>

Run CLI Commands

Launch the SSH terminal and connect to your store. Go to the root directory of your store and run the following commands:

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
php bin/magento cache:clean
php bin/magento cache:flush

Go to the store and you will see the result:

Edit and Add New Link in Magento 2 Footer - Result

Final Words

You can now easily edit footer of your Magento 2 store. The process is simple and allows you to remove and add links in Magento 2 footer to fit your store marketing strategy. As always, if you need help, just drop a comment and I will get back to you.

 

Subscribe Newsletter

Subscribe to get latest Magento news

40% Off for 4 Months on Magento Hosting + 30 Free Migration