2

I'm trying to remove the main menu from the homepage, for this I used the following code in my custom template:

<referenceBlock name="store.menu" remove="true" />

But the menu is still there while other settings in the template work fine.

What else should I do to remove this main menu ?

3 Answers 3

2

To remove the main menu from your home page do the following thing

Create your own theme at this location

magento_root\app\design\frontend\Themes_package\theme\

Create a theme folder there at below location

magento_root\app\design\frontend\Themes_package\theme\Magento_Theme

Create a default.xml file there at below location

magento_root\app\design\frontend\Themes_package\theme\Magento_Theme\layout\default.xml

Put this code there

<?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="navigation.sections" remove="true"/>
    </body>
</page>

This will remove your navigation section

Thank You!

1
  • Thanks for your answer which helped me finding the correct block. However, I just needed to do it for the homepage, not for all pages.
    – DevonDahon
    Nov 17, 2017 at 5:25
1

In more recent versions of Magento2, the remove method is now:

<referenceBlock name="block_name" remove="true"/>

Example:

<?xml version="1.0"?>
<page layout="3columns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="block_name" remove="true"/>
    </body>
</page>
1

The final answer is:

<referenceContainer name="header-wrapper">
        <referenceBlock name="navigation.sections" remove="true" />
</referenceContainer>

I wasn't referring to the correct block and, for some reason, I had to add a reference to the container.

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.