How to add link on my account navigation in Magento 2 – In this tutorial, we’re going to add a new link to my account navigation in Magento 2.
You only need to create a layout file:
/app/code/YourVendor/YourModule/view/frontend/layout/customer_account.xml
with content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="customer_account_navigation"> <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-mymodule-index-index"> <arguments> <argument name="path" xsi:type="string">mymodule/index/index</argument> <argument name="label" xsi:type="string">My Custom Link</argument> </arguments> </block> </referenceBlock> </body> </page> |
In this file “mymodule/index/index” is url path of your link and “My Custom Link” is the label.
After flushing cache, your account navigation should look like this:
