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


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 main menu on CMS pages add below code in app\design\frontend\<Vendor>\<Themename>\Magento_Cms\layout\cms_page_view.xml file.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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