Magento2: what is the difference between layout and page_layout?

Well if i put this in simple words than

page_layout represents the full page, i mean you can declare your own full page without inheriting any master or root or other empty layout. (only use, if you want to completely customize your own full page.)

layout represents the part of the page (mostly the html content). You can use this when you want your page to inherit the common contents from the root layout like header, footer etc etc.


Page layout declares the wireframe of a page inside the section, for example one-column layout or two-column layout.

Allowed layout instructions:

 <container>
 <referenceContainer>
 <move>
 <update>

Generic layouts define the contents and detailed structure inside the <body> section of the HTML page markup.

Conventionally generic layout files must be located as follows:

Module generic layouts: <module_dir>/view/frontend/layout
Theme generic layouts: <theme_dir>/<Namespace>_<Module>/layout

Follow this link for overview of layout overview: http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/layout-overview.html

And some more detailed information about the layout file types: http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/layout-types.html


Layout XML is a tool to build the pages of the Magento application in a modular and flexible manner. It enables us to describe the page layout and content placement.

Looking at XML root nodes, we differentiate two types of layouts:

1. layout: XML wrapped in <layout>
2. page: XML wrapped in <page>

Page layouts represent a full page in HTML, whereas layout layouts represent a part of a page.

The layout type is a subset of the page layout type. Both types of layout XML files are validated by the XSD schema found under the vendor/magento/framework/View/Layout/etc/ directory:

1. layout – layout_generic.xsd
2. page – page_configuration.xsd

Based on the application components that provide and elements, we can further section them as base and theme layouts.

The base layouts are provided by the modules, usually at the following locations:

1. <module_dir>/view/frontend/layout: page configuration and generic layout files
2. <module_dir>/view/frontend/page_layout: page layout files

The theme layouts are provided by the themes, usually at the following locations:

1. <theme_dir>/<Namespace>_<Module>/layout: page configuration and generic
layout files
2. <theme_dir>/<Namespace>_<Module>/page_layout: page layout files

Magento will load and merge all module and theme XML files on the appropriate page.

Once files are merged and XML instructions are processed, the result is rendered and sent to the browser for display.

Tags:

Magento2