Magento – How to remove container from homepage only

custom-thememagento2page-layouts

I added div(container) in every page except homepage like this

<main>
        <div class="myclass">
              all content here
        </div>
    </main>

I tried update layout from admin and cms_index_index.xml file by using remove tag but doesn't work for me. I only need to remove that container class or div not all child blocks & containers

Let's consider my container in my empty.xml (override).

<container name="container_name" htmlClass="myclass" htmlTag="div"/>

It's come as I want but I don't want it on homepage

How can I remove that container from homepage.

Best Answer

You can remove class by this way:

Go to your admin panel > cms home page. There is one tab DESIGN and in this tab add your XML code in Layout Update XML area.

<referenceContainer name="container_name" htmlClass="">

Keep empty so it will remove the class.

Run command:

php bin/magento cache:flush