Difference Between "page" and "layout" Root Tags in Magento 2

These matters due to a different XSD configurations. The

<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">

declaration says that we want to use layout with XSD definition provided in the

lib/internal/Magento/Framework/View/Layout/etc/layout_generic.xsd

In the layout_generic.xsd file it provides definition for layout node with genericLayout element type.

<xs:complexType name="genericLayout">
    <xs:sequence minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="referenceContainer" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="container" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="block" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="referenceBlock" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="update" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="move" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="uiComponent" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
</xs:complexType>

Having that, the layout file has been validated by the XSD when xml is loaded. In addition to this it highlights all possible nodes and node attributes in the layout.xml file.

Same with page_configuration.xsd definition for <page /> node. This XSD describes nodes which can be used to describe page.

Hope it helps.


Layout files which open with <layout></layout> are page layouts that declare the wireframe of a page inside the <body> section, for example one-column layout or two-column layout.

The layout files which open with <page></page> are page configuration files that add content to the wireframe defined in a page layout file.

Here is the official doc about it, please let us know if it can be improved: http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/layout-types.html