Hide the main menu for home page and main menu display for another pages in magento2.?
2 Answers
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!
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" />
-
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.– zusCommented 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 fordisplay: block;
for perticular element. You can refere screenshot here: prnt.sc/wb85fe. Commented Dec 28, 2020 at 5:33 -
-
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