I have created a cms block and using widget added inside header page container, now I want to remove that block from only home page.
How can i achieve this?
Widget screenshot to display block
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityGo to
Admin -> Content -> Pages -> Edit CMS page (which you want to update) -> Design -> Layout Update XML
And then, post this below code in that field
<referenceContainer name="content.top">
<referenceBlock name="form.popup.subscribe" remove="true"/>
</referenceContainer>
You can set name of referenceContainer and referenceBlock name which you want to remove.
Hope, It will helpful for you !!
From Layout file:
Goto app/design/frontend/[VendorTheme]/[ThemeName]/Magento_Cms/layout/cms_index_index.xml and add below code. BlockName will be the name of block which you want to delete.
<?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>
<!-- add this code for remove block -->
<referenceBlock name="BlockName" remove="true"/>
</body>
</page>
Into the CMS home page, Design -> Layout Update XML
<referenceBlock name="BlockName" remove="true"/>
save the cms page and clear the cache.
without xml you want to hide them using css display none.
create below file
app/design/frontend/name/example/Magento_CMS/layout/cms_index_index.xml
<referenceBlock name="block_name" remove="true"/>
add below code and add your static block_name Example:
<?xml version="1.0"?>
<page layout="1column" 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>
It would be best if you put the following code:
<referenceBlock name="block_name" remove="true"/>
in the Design >> Layout Update XML section of your CMS Home page in the admin panel.
After that, you just need to flush Magento's cache.
Since Magento provides to update the layout of CMS pages from the backend, there is no need to do it using the layout files.
I hope it is clear.