Layout file types
Page layout
A page layout file defines the page wireframe, for example, one-column layout. Technically page layout is an .xml file defining the structure inside the <body>
section of the HTML page markup. Page layouts feature only containers. All page layouts used for page rendering should be declared in the page layout declaration file.
Allowed layout instructions:
<container>
<referenceContainer>
<move>
<update>
Sample page layout:
<Magento_Theme_module_dir>/view/frontend/page_layout/2columns-left.xml
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
<update handle="1column"/>
<referenceContainer name="columns">
<container name="div.sidebar.main" htmlTag="div" htmlClass="sidebar sidebar-main" after="main">
<container name="sidebar.main" as="sidebar_main" label="Sidebar Main"/>
</container>
<container name="div.sidebar.additional" htmlTag="div" htmlClass="sidebar sidebar-additional" after="div.sidebar.main">
<container name="sidebar.additional" as="sidebar_additional" label="Sidebar Additional"/>
</container>
</referenceContainer>
</layout>
To be able to use a layout for actual page rendering, you need to declare it in layouts.xml
.
Page configuration
Page configuration is also an .xml
file. It defines the detailed structure (page header, footer, etc.), contents and page meta information, including the page layout used. Page configuration features both main elements, blocks of particular classes and containers.
Element | Attributes | Parent of | Description |
---|---|---|---|
<page></page>
|
|
|
Mandatory root element. |
<html></html> |
none |
|
Mandatory element. |
<head></head> |
none |
|
|
<body></body> |
none |
|
|
<attribute> |
|
Specified for
|
|
|
none | none | Page title |
|
|
none | |
|
|
none | |
<css>
|
|
none | |
|
|
none |
Generic layouts
They are .xml
files which define the contents and detailed structure inside the <body>
section of the HTML page markup. These files are used for pages returned by AJAX requests, emails, HTML snippets and so on.