Magento 2 add or remove link in customer navigation

0
28

Add a Custom Link

Create customer_account.xml in location Namespace/ModuleName/view/frontend/layout

<?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="customer_account_navigation">
            <block class="Magento\Framework\View\Element\Html\Link\Current" name="demo-link">
                <arguments>
                    <argument name="path" xsi:type="string">module/controller/action</argument>
                    <argument name="label" xsi:type="string">Demo Link</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

Result will be look likes the image.

Link

Remove the link

Example: remove Address link

<!-- Address link -->
<referenceBlock name="customer-account-navigation-address-link" remove="true"/>