Question

\vendor\magento\module-catalog\view\frontend\layout\catalog_product_view.xml is the layout xml file for Product Detail Page.

Where are the layout xml files for Homepage and for Category Page (page that shows after clicking on a category link ex. 'http://127.0.0.1/magento/category-1.html', where layered navigation is displayed) ?

what I mean by Catgory Page: enter image description here

thanks

Was it helpful?

Solution

Magento-2 file path hierarchy

First check in your current theme

app/design/frontend/YourTheme/ThemePackage/Magento_Catalog/layout/catalog_category_view.xml
app/design/frontend/YourTheme/ThemePackage/Magento_Cms/cms_index_index.xml

Second check in your current theme parent theme.

app/design/frontend/CurrentParentTheme/ThemePackage/Magento_Catalog/layout/catalog_category_view.xml
app/design/frontend/CurrentParentTheme/ThemePackage/Magento_Cms/cms_index_index.xml

Third check in core module.

vendor/magento/module-cms/view/frontend/layout/cms_index_index.xml
vendor/magento/module-catalog/view/frontend/layout/catalog_category_view.xml

For home page you have to check in current assign home page

Admin >> Content >> Pages >> Selecte your current home page.

Check home page content and Layout Update XML in Design tab.

OTHER TIPS

The homepage is vendor/magento/module-cms/view/frontend/layout/cms_index_index.xml. Category page is vendor/magento/module-catalog/view/frontend/layout/catalog_category_view.xml.

Remove all content from default.xml that should be displayed on the homepage, content region, e.g. all of your custom blocks.

Then create a file called cms_index_index.xml in the same place where your default.xml lives, with the following content:

<?xml version="1.0"?>
<!--
/**
 * cms_index_index.xml
 *
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 * 
 * This file only is displayed on the homepage of magento
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

    <referenceContainer name="content">
        <!-- Insert your blocks just for the homepage here, e.g. -->
        <container htmlTag="section" htmlClass="widget block block-static-block newsletter-block">
            <block class="Magento\Cms\Block\Widget\Block" name="newsletter" template="Magento_Theme::html/subscribe.phtml">
                <arguments>
                    <argument name="block_id" xsi:type="string">newsletter</argument>
                </arguments>
            </block>
        </container>
        <container htmlTag="section" htmlClass="widget block block-static-block view-catalogue-block">
            <block class="Magento\Cms\Block\Widget\Block" name="view_catalogue" template="Magento_Theme::html/view-catalogue.phtml">
                <arguments>
                    <argument name="block_id" xsi:type="string">view_catalogue</argument>
                </arguments>
            </block>
        </container>

        </referenceContainer>

    <body/>
</page>

Tested on Magento 2.2

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top