Easiest way to achieve this without using code is from admin panel.
In the Magento Admin(backend),
Create the block by following the below steps:
- Content -> Blocks
- Add new Block
- Block Title = Footer Links Block
- Identifier = footer_links_block
- Store View = All Store Views (or whatever store views it applies to, does not apply when using single store mode)
- Click Show/Hide Editor and enter the following (not in WYSIWYG editor):
- Save
Now Create a Widget
- Content > Widgets
- Add Widget
- Type = CMS Static Block
- Design Package/Theme = Luma (or whatever theme you are using)
- Click Continue
- Widget Title = Footer Links
- Assign to Store Views = All Store Views (or whatever store views it applies to, does not apply when using single store mode). Now,Layout Updates:
- Display on All Pages
- Container = CMS Footer Links
- Widget Option > Select Block > Footer Links Block
- Save
Refresh the needed caches:
System > Cache Management
Select invalidated caches and refresh
And you are good to go! It will add your own link after the default footer links. But if you want to remove the default links and make your own then you can follow the second way of doing this.
The other way is to code.
Create a custom module based on Magento 2 structure in the folder app/code.
/app/code/Dckap/Newlink/
Create module.xml file in the below path to define your Magento 2 extension.
/app/code/Dckap/Newlink/etc/module.xml
<?xml version=“1.0”?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Dckap_Newlink" setup_version="2.0.1"></module>
</config>
Create routes.xml in the below path for your custom link.
/app/Dckap/Newlink/etc/frontend/routes.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd">
<router id="standard">
<route id="newlink" frontName="newlink">
<module name="Dckap_Newlink" />
</route>
</router>
</config>
/app/Dckap/Newlink/view/frontend/layout/footer.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<page>
<referenceBlock name="footer_links">
<block class="Magento\Framework\View\Element\Html\Link\Current" name="2custom-link">
<arguments>
<argument name="label" xsi:type="string">Footer Link</argument>
<argument name="path" xsi:type="string">testuser</argument>
</arguments>
</block>
</referenceBlock>
</page>
After completing the above steps run the below Magento 2 upgrade command in the command prompt.
php bin/magento setup:upgrade
Check the browser to see your custom footer links.