As per as, Magento2, default.xml
is call at every page.If you add this code at default.xml
then it would be automatically call every pages of your current theme.
If you know about Magento 1.x handler concept then you can understand that default
is a handle which is called at every pages.In Magento 2.X,every handler is individual layout files.
So if want to add a phtml file only at home page then you need to add that code at cms_index_index.xml
(/app/design/frontend/name/themename/Magento_Cms/layout/cms_index_index.xml
) layout file because of cms_index_index
is handler which call only called at home
When creating any new theme or module you need to define registration.php file at root of your module or theme folder.
Always use theme name in lowercase, Because Magento used this standard
for theme name declaration.
You haven't any problem for keep Theme name in camelcase but use standard way is much appreciated.
You have to define registration.php file inside Magento_Theme folder, its in wrong place.
Correct diagram of theme structure will be below,
magento2
|_ app
|_ design
|_ frontend
|_ Custom
|_theme
|_Magento_Theme
|_templates
|_root.phtml - Copy of Luma
|_registration.php
|_theme.xml
Your path for registration.php is app\design\frontend\Custom\theme\registration.php
registration.php file :
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::THEME,
'frontend/Custom/theme',
__DIR__
);
your theme.xml file path will be,
app\design\frontend\Custom\theme\theme.xml
theme.xml file :
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
<title>Custom Theme</title>
<parent>Magento/luma</parent>
<media>
<preview_image>media/preview.jpg</preview_image>
</media>
</theme>
After all setup is completed, don't forget to run deploy command for the theme,
php bin/magento setup:static-content:deploy
Check inside your admin panel, Content -> Design -> Configuration
for set your custom theme.
Remove cache and check in the frontend.
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
From Layout file:
Goto app/design/frontend/[VendorTheme]/[ThemeName]/Magento_Cms/layout/cms_index_index.xml and below code