1

Hide the main menu for home page and main menu display for another pages in magento2.?

2 Answers 2

1

The homepage has an unique class on the body element, like: "cms-home".

After you identify that class, add a css property to hide the menu in a css file that is included on homepage, like this:

.cms-home .navigation {display: none;}

I hope it helps!

1

For hide main menu in CMS pages add below style:

.cms-page-view .nav-sections {display: none;}

And if you want to remove the main menu for all CMS pages add the below code in app\design\frontend\<Vendor>\<Themename>\Magento_Cms\layout\cms_page_view.xml file.

<referenceBlock name="navigation.sections" remove="true" />

AND

If you want to remove the main menu for Home page add the below code in app\design\frontend\<Vendor>\<Themename>\Magento_Cms\layout\cms_index_index.xml file.

<referenceBlock name="navigation.sections" remove="true" />
4
  • Hi @Dipesh Rangani, i have added customer links into nav section (menu bar), but its hiding, when i inspect element all the codes available, i just did <move element="header.links" destination="catalog.topnav" after="-"/> any help thanks.
    – zus
    Commented Dec 25, 2020 at 15:06
  • Hi @zus, There is default Magento CSS .nav-sections-item-content>* { display: none; } that's why you have to add css for display: block; for perticular element. You can refere screenshot here: prnt.sc/wb85fe. Commented Dec 28, 2020 at 5:33
  • can you pls help me magento.stackexchange.com/q/328503/57334
    – zus
    Commented Dec 28, 2020 at 5:51
  • We can use layout update of the cms page (home). More Info: docs.magento.com/user-guide/design/… Commented Mar 6, 2022 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.