How to Remove Top Link in Magento 2
Previously, I had given the programmatic solution to add top link in Magento 2.
However, you may need to perform the reverse action, i.e., remove top link in Magento 2. There can be many reasons to do so. For example, you had added a link for testing purpose but now changed your mind. Or, you want to disable new registration temporarily. In cases when you want to change the labels of top links or override the default functionality, you can also use the below solution.
Method to Remove Top Link in Magento 2:
Create default.xml at Vendor/Extension/view/frontend/layout/ folder
1 2 3 4 5 6 7 8 9 |
<?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="register-link" remove="true" /> <!--for Create Account Link--> <referenceBlock name="authorization-link" remove="true" /> <!--for Sign In Link --> <referenceBlock name="wish-list-link" remove="true" /> <!--for WishList Link--> <referenceBlock name="my-account-link" remove="true" /> <!--for My Account Link--> </body> </page> |
That’s it.
Implement the above code and remove top links in the Magento 2 store.
Efficiently manage the top links for an optimized and easy-to-shop frontend!
Use the Comments section below if you have any doubts on the topic. Also, let me know how the solution was useful to optimize your store frontend.
I’d be very grateful if you help share this helpful post on social media to fellow developers!
Thanks!
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
Prev
How to Auto Approve Product Review For Registered Customers in Magento 2
How to Programmatically Create Multi Select Product Attribute in Magento 2
Next