Managing My Account Navigation Links in Magento 2

Looking at the old articles on our website that long for a rewrite, I sometimes stumble upon a gem that can be useful. This is a rewrite of the article originally written for Magento 1 – Managing navigation links in the account dashboard
In this article I’ll demonstrate how to manage navigation links in your customer’s account dashboard.
Step 1
First of all, you need a create customer_account.xml in your theme in:
app/design/frontend/_YOUR_VENDOR_/_YOUR_THEME_/Magento_Customer/layout/customer_account.xml
Add a Custom Link
All we need to do is add this code to our layout xml file:
<referenceBlock name="customer_account_navigation">
<block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-custom-link" after="-" >
<arguments>
<argument name="label" xsi:type="string" translate="true">Custom Link Label</argument>
<argument name="path" xsi:type="string">custom-path</argument>
</arguments>
</block>
</referenceBlock>
Re-order links
<move element="LINK_YOU_WANT_TO_MOVE" destination="customer_account_navigation" AFTER_OR_BEFORE="NEW_POSITION" />
<!-- eg. "My Wish List" move after "My Orders" -->
<move element="customer-account-navigation-wish-list-link" destination="customer_account_navigation" after="customer-account-navigation-orders-link" />
We “moved” the element from its original location and placed it back there, at the same time telling M2 to place it after/before link we want.
Remove the link
To shorten and simplify the story, in the example below I will immediately show you how to delete all links from the navigation one by one.
<!-- Store credit -->
<referenceBlock name="customer-account-navigation-customer-balance-link" remove="true"/>
<!-- Downloadable product link -->
<referenceBlock name="customer-account-navigation-downloadable-products-link" remove="true"/>
<!-- Subscription link -->
<referenceBlock name="customer-account-navigation-newsletter-subscriptions-link" remove="true"/>
<!-- Billing agreement link -->
<referenceBlock name="customer-account-navigation-billing-agreements-link" remove="true"/>
<!-- Product review link -->
<referenceBlock name="customer-account-navigation-product-reviews-link" remove="true"/>
<!-- My credit card link -->
<referenceBlock name="customer-account-navigation-my-credit-cards-link" remove="true"/>
<!-- Account link -->
<referenceBlock name="customer-account-navigation-account-link" remove="true"/>
<!-- Account edit link -->
<referenceBlock name="customer-account-navigation-account-edit-link" remove="true"/>
<!-- Address link -->
<referenceBlock name="customer-account-navigation-address-link" remove="true"/>
<!-- Orders link -->
<referenceBlock name="customer-account-navigation-orders-link" remove="true"/>
<!-- Wish list link -->
<referenceBlock name="customer-account-navigation-wish-list-link" remove="true"/>
<!-- Gift card link -->
<referenceBlock name="customer-account-navigation-gift-card-link" remove="true"/>
<!-- Gift registry -->
<referenceBlock name="customer-account-navigation-giftregistry-link" remove="true"/>
<!-- Reward points -->
<referenceBlock name="customer-account-navigation-reward-link" remove="true"/>
<!-- Order by SKU -->
<referenceBlock name="customer-account-navigation-checkout-sku-link" remove="true"/>
Hope this helps someone!
10 comments
Hi Matej Djakovic,
Can we move Left nav to top(horizontally) and how we can do that?
This saved much time at the right time!
Please also tell how can we add dynamic text in this left menu.
For eaxmaple, I want to add a new tab
‘Notifications’
but with COUNT of new notifications like below:
Notifications (3)
the “(3)” will be total unread notification count coming from DB.
Please tell how to achieve that…
I can’t change the order of the RMA link
hi, from where did you find those id names?
This is not working in magento 2.2.2 ?
Hi Mohit,
works also on Magento 2.2.2
Easier than Magento 1, thank you 🙂
waooo.. this blog help me to solve customer account link issue…
It helped me! Thank you for sharing. 🙂
Thank’s so much for taking the time to share your knowledge 🙂