cancel
Showing results for 
Search instead for 
Did you mean: 

How can I edit top navigation menu?

How can I edit top navigation menu?

How can I edit top navigation menu? Is it possible to add new menus at top? And is it possible to delete some menus from top?

8 REPLIES 8

Re: How can I edit top navigation menu?

If you are talking about the Catalog Navigation this link will be helpful for you:

https://docs.magento.com/m2/ce/user_guide/catalog/navigation-top.html

 

If you are taking about header links you can add new links by create below files:

app/design/frontend/vendor/theme/Magento_Theme/layout/default.xml

 

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
            <body>
            <referenceBlock name="header.links">
                <block class="Magento\Framework\View\Element\Html\Link" name="custom-link">
                <arguments>
                    <argument name="label" xsi:type="string" translate="true">custom link</argument>
                    <argument name="path" xsi:type="string" translate="true">customlink</argument>
                </arguments>
                </block>
            </referenceBlock>

            </body>
        </page>

If you want to remove any link:

Add default.xml file in this path

app/design/frontend/vendor/theme/Magento_Theme/layout/default.xml

 

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn: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>

Hope it will be helpful for you

Re: How can I edit top navigation menu?

"app/design/frontend/vendor/theme/Magento_Theme/layout/default.xml"

 

should it be "app/design/frontend/Magento/theme-frontend-luma/Magento_Theme/layout/default.xml" ? (if i want to customize luma theme)

Re: How can I edit top navigation menu?

Yes, you can edit this and then flush cache and check if it works for you.

Or if you have a custom module you can also place default.xml in your custom module and update it the file path will be something like this:

app\code\MyModule\Custommodule\view\frontend\layout\default.xml

in this file you can place the same code which I have shared in my previous answer.

Re: How can I edit top navigation menu?

"app/design/frontend/vendor/theme/Magento_Theme/layout/default.xml" what is vendor and theme here?

 

Can you post example code to do this with custom module?

Re: How can I edit top navigation menu?

Here vendor is Vendor's Name i.e Company's Name who is creating this custom theme and "theme" keyword is representing the name of Theme.

If you want you can also create your own theme under app/design/frontend/companyname/themename/....

 

If you have already created custom module under app/code then you can place the default.xml, in my case the path is:


app\code\Aman\Custom\view\frontend\layout\default.xml

 

and the code I have added is:

<?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="header.links">
         <block class="Magento\Framework\View\Element\Html\Link" name="custom-link">
            <arguments>
                <argument name="label" xsi:type="string" translate="true">New Link</argument>
                <argument name="path" xsi:type="string" translate="true">new-link</argument>
            </arguments>
         </block>
     </referenceBlock>
      <referenceBlock name="register-link" remove="true" />
    </body>

If you want to learn how to create custom module in Magento 2 you can have a look on this link:

http://inchoo.net/magento-2/how-to-create-a-basic-module-in-magento-2/

Re: How can I edit top navigation menu?

Hi there, 

Maybe you are facing some problems with traditional Magento menu? 

You seem to be not very good at coding when asking this question. 
We do understand your situation. Thus, we provide you with a Magento 2 mega menu - Ninja Menus that can absolutely help! 
Edit top navigation menu at a glance with the intuitive drag and drop interface. No coding need!2. Magento 2 Mega Menu - Drag & Drop.pngMagento-2-mega-menu-_-3-different-type.pngMagento 2 mega menu - Fully responsive.pngMagento 2 mega menu - Customise menu.png
Plus, wanna add new menus at the top? With our widget features, you can add them to anywhere in your storefront. 
Check out the below links to see how amazing Ninja Menus: 

https://www.youtube.com/watch?v=HPan7HtIYOw

 

Trusted Magento 2 Extensions

Re: How can I edit top navigation menu?

By adding Magento 2 Mega Menu Extension you can do that. It helps you to create a menu fast and easily in Magento 2 . It allows you to have multiple options to show what you want on the main navigation.

MEGA MENU 2 - FEATURES

  • Allow to add unlimited menu
  • Automatically generate the code to add menu to everywhere you want
  • Allow to add different menu for different store
  • Allow to create menu for category, cms page or any URL
  • Support multiple columns
  • Easy to add category links to menu
  • Allow to add icon/custom HTML to menu
  • Support custom class to help you easily customize style for menu
  • Allow to use editor to edit content easier
  • Allow to insert whatever widgets (similar to widget insertion of a CMS page)
  • Allow to embed video, frame to menu content
  • Support for mobile menu

Re: How can I edit top navigation menu?

Hi there,

 

by way of a workaround (that works) try using a server redirect:

 

1/ make a category and add it to the menu and note down its URL

2/ add a redirect to the .htaccess file to go to where you want it to go instead.

 

redirect 301 /servicing.html /servicing-and-maintenance

 

hope this helps someone in the future!

 

L