Magento 2 – Remove CMS Content from Homepage

layoutmagento2

I'm trying to remove the cms content from the homepage, whilst keeping all the meta stuff from the CMS panel.

So initially i was using:

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

which removes the cms content but it also removes all the meta stuff as well. I can remove the Page header ok with:

<referenceBlock name="page.main.title" remove="true" />

but this still keeps the cms content.

In a nut shell i have several .phtml blocks on this page which i'm including in cms_index_index.xml like so:

<referenceContainer name="content">
    <block class="Magento\Framework\View\Element\Template" name="block1" template="Magento_Cms::home/block1.phtml" />
    <block class="Magento\Framework\View\Element\Template" name="block2" template="Magento_Cms::home/block2.phtml" />
    <block class="Magento\Framework\View\Element\Template" name="block3" template="Magento_Cms::home/block3.phtml" />
    <block class="Magento\Framework\View\Element\Template" name="block4" template="Magento_Cms::home/block4.phtml" />
</referenceContainer>

i know i could add this as the 'cms content' but this isn't really an option as the people who would be updating the meta shouldnt be able to edit the cms content.

basically i just want a thing similar to this:

or the ability to remove 'cms_page' and then re-add the meta options after.

Best Answer

So my solution to keep the meta content working from the CMS page but removing the cms content from the page goes like this:

<!-- remove page title -->
<referenceBlock name="page.main.title" display="false"/>
<!-- remove cms content block (but keep the cms part so meta data can be updated) -->
<referenceBlock name="content" display="false"/>

<!-- add new homepage content -->
<referenceContainer name="main">
    <container name="home.content" htmlTag="div" before="-">
        <block class="Magento\Framework\View\Element\Template" name="block1" template="Magento_Cms::home/block1.phtml" />
        <block class="Magento\Framework\View\Element\Template" name="block2" template="Magento_Cms::home/block2.phtml" />
        <block class="Magento\Framework\View\Element\Template" name="block3" template="Magento_Cms::home/block3.phtml" />
        <block class="Magento\Framework\View\Element\Template" name="block4" template="Magento_Cms::home/block4.phtml" />
    </container>
</referenceContainer>
Related Topic