Magento – how to remove phtml file from home page in magento 2 theme

blockshomelayoutmagento2

How can I remove a phtml template file from my theme, but only from the home page?

My template file is "custome_home.phtml" at app/design/frontend/kalpak/ktheme/Magento_Theme/templates/html

Best Answer

First,you should find custome_home.phtml block name layout files or from backedn,

then using <referenceBlock name="BlockName" remove="true"/> from lyaout.

There are two way,you can do this:

From admin

Goto admin>Content>Page> then select your cms page>

and after that add below at code Design tab at your CMS home page at backend

<referenceContainer name="ParentContainerName">
     <referenceBlock name="BlocknameatLyaout" remove="true"/></referenceContainer>

From Layout file:

Goto app/design/frontend/[VendorTheme]/[ThemeName]/Magento_Cms/layout/cms_index_index.xml and below code

 <?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>
Related Topic