{"id":16359,"date":"2018-07-26T16:25:39","date_gmt":"2018-07-26T14:25:39","guid":{"rendered":"https:\/\/belvg.com\/blog\/?p=16359"},"modified":"2026-07-08T13:21:51","modified_gmt":"2026-07-08T11:21:51","slug":"working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2","status":"publish","type":"post","link":"https:\/\/belvg.com\/blog\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html","title":{"rendered":"How Do Magento Blocks and Layouts Work In 2026?"},"content":{"rendered":"\n<p>In Magento 2, the frontend is built around layouts, containers, blocks, and templates. Layouts define the page structure through XML, containers organize structural areas of the page, blocks provide PHP logic and data, and templates (.phtml files) generate the HTML output. This system allows developers to modify pages through modules and themes without editing Magento core files.<\/p>\n<p><!--more--><\/p>\n<p>Magento 2 continued the idea of separating frontend elements into reusable components, but introduced a different layout system based on XML merging, dependency injection, and module-based customization. How is it implemented in Magento 2?<\/p>\n<p>Here some definitions for a better understanding of the topic of this article:<\/p>\n<ol>\n<li>Layout &ndash; defines the structure of the page using XML layout files. Magento provides default page layouts such as empty.xml, 1column.xml, 2columns-right.xml, 2columns-left.xml, and 3columns.xml, but themes and modules can introduce custom layouts.<\/li>\n<li>Container &ndash; defines structural areas of a page and organizes child blocks and containers. Containers can add HTML wrappers and control the position of their child elements.<\/li>\n<li>Block is a PHP class that provides data and logic to a template. The related template file (.phtml) is responsible for generating HTML output.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/07\/image22.png\"><img decoding=\"async\" loading=\"lazy\" class=\"lazy aligncenter wp-image-16361 size-full\" src=\"https:\/\/belvg.com\/wp-content\/uploads\/2019\/06\/pixel.png\" data-src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/07\/image22.png\" alt=\"Page structure\" width=\"950\" height=\"388\" title=\"How Do Magento Blocks and Layouts Work In 2026?\"><\/a><\/p>\n<p>To understand how this works, let&rsquo;s take a look at the basic Magento_Theme module.<\/p>\n<h2><strong><span style=\"color: #000000;\">How page structures are defined<\/span><\/strong><\/h2>\n<p><a href=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/07\/image42.png\"><img decoding=\"async\" loading=\"lazy\" class=\"lazy aligncenter wp-image-16362 size-full\" src=\"https:\/\/belvg.com\/wp-content\/uploads\/2019\/06\/pixel.png\" data-src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/07\/image42.png\" alt=\"Folder structure\" width=\"885\" height=\"806\" title=\"How Do Magento Blocks and Layouts Work In 2026?\"><\/a><\/p>\n<p>First of all, when building a page Magento 2 reads the <em>&ldquo;page_layout&rdquo;<\/em> directory, which contains xml instructions. Let&rsquo;s consider how <em>&ldquo;emtpy.xml&rdquo;<\/em> works since other layout files use it as a parent one.<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;layout xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_layout.xsd\"&gt;\r\n&nbsp;&nbsp;&lt;container name=\"root\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"after.body.start\" as=\"after.body.start\" before=\"-\" label=\"Page Top\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"page.wrapper\" as=\"page_wrapper\" htmlTag=\"div\" htmlClass=\"page-wrapper\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"global.notices\" as=\"global_notices\" before=\"-\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"main.content\" htmlTag=\"main\" htmlId=\"maincontent\" htmlClass=\"page-main\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"columns.top\" label=\"Before Main Columns\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"columns\" htmlTag=\"div\" htmlClass=\"columns\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"main\" label=\"Main Content Container\" htmlTag=\"div\" htmlClass=\"column main\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/container&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/container&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"page.bottom.container\" as=\"page_bottom_container\" label=\"Before Page Footer Container\" after=\"main.content\" htmlTag=\"div\" htmlClass=\"page-bottom\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"before.body.end\" as=\"before_body_end\" after=\"-\" label=\"Page Bottom\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/container&gt;\r\n&nbsp;&nbsp;&lt;\/container&gt;\r\n&lt;\/layout&gt;\r\n<\/pre>\n<p>As you can see, this layout file consists of parts called &ldquo;container&rdquo;. This file contains more general page blocks and does not include the container &ldquo;header&rdquo;. A container is different from a block. It is a structural element that organizes child blocks and containers. Unlike blocks, containers normally do not have a PHP class or template file.&nbsp;A block with the <em>container<\/em> type will automatically output html from the blocks that refer to it.<\/p>\n<p>Blocks such as <em>1column.xml, 2columns-right.xml, 2columns-left.xml, 3columns.xml<\/em> have a similar structure and complement <em>empty.xml<\/em>. For example, <em>1column.xml<\/em> adds a header and a footer:<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;layout xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_layout.xsd\"&gt;\r\n&nbsp;&nbsp;&lt;update handle=\"empty\"\/&gt;\r\n&nbsp;&nbsp;&lt;referenceContainer name=\"page.wrapper\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"header.container\" as=\"header_container\" label=\"Page Header Container\" htmlTag=\"header\" htmlClass=\"page-header\" before=\"main.content\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"page.top\" as=\"page_top\" label=\"After Page Header\" after=\"header.container\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;container name=\"footer-container\" as=\"footer\" before=\"before.body.end\" label=\"Page Footer Container\" htmlTag=\"footer\" htmlClass=\"page-footer\"\/&gt;\r\n&nbsp;&nbsp;&lt;\/referenceContainer&gt;\r\n&lt;\/layout&gt;<\/pre>\n<p>Similarly, <em>2columns-left.xml<\/em> will add a container to display the left column with additional information: <em>sidebar_main, sidebar_additional.<\/em><\/p>\n<p>Considering all the above mentioned, you can identify the main containers that are used in Magento 2:<\/p>\n<p>container name = &ldquo;root&rdquo;&mdash; is used to add basic containers;<\/p>\n<p>container name = &ldquo;header.container&rdquo; &mdash; displays the top of the page, the so-called &ldquo;header&rdquo;;<\/p>\n<p>container name = &ldquo;main.content&rdquo;&nbsp;&mdash; displays the main content of the page (body);<\/p>\n<p>container name = &ldquo;footer-container&rdquo;&nbsp;&mdash; is responsible for displaying content in footer.<\/p>\n<p>Of course, these are not all the containers that are used to build a page, but knowing where these files (empty.xml, 1column.xml, 2columns-right.xml, 2columns-left.xml, 3columns.xml, etc.,) are located, you can always look up the names of the required containers.<\/p>\n<h2><strong><span style=\"color: #000000;\">The role of blocks and templates in the request flow<\/span><\/strong><\/h2>\n<p>Now that the page structure from the basic containers is defined, you can add smaller parts of the page. In Magento 2 they are called blocks. Blocks separate PHP logic from HTML markup. Each block is represented by a PHP class and can be connected to a template file. The block prepares data, while the template generates the final HTML output. You can see this more clearly if you look at the connection of the blocks. For example, consider the layout &ndash; <em>default.xml<\/em> file of the <em>Magento_Customer<\/em> module and the part that is responsible for adding the authorization link.<\/p>\n<pre class=\"lang:xhtml decode:true\">\/**\r\n*vendor\/magento\/module-customer\/view\/frontend\/layout\/default.xml\r\n*\/\r\n&lt;referenceBlock name=\"top.links\"&gt;\r\n&hellip;&hellip;..\r\n&nbsp;&nbsp;&lt;block class=\"Magento\\Customer\\Block\\Account\\AuthorizationLink\" name=\"authorization-link\"\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;template=\"account\/link\/authorization.phtml\"\/&gt;\r\n&lt;\/referenceBlock&gt;<\/pre>\n<p>When rendering a Magento 2 page, it will call the <em>Magento\\Customer\\Block\\Account\\AuthorizationLink<\/em> class, which in its turn calls the <em>account\/link\/authorization.phtml<\/em>&nbsp;template indicated in the layout.<\/p>\n<p>Now, from the <em>account\/link\/authorization.phtml<\/em>&nbsp;template, you can access all the open methods of the <em>Magento\\Customer\\Block\\Account\\AuthorizationLink<\/em> class using the <em>$block<\/em> variable.<\/p>\n<pre class=\"lang:php decode:true\">\/**\r\n*vendor\/magento\/module-customer\/view\/frontend\/templates\/account\/link\/authorization.phtml\r\n*\/\r\n$dataPostParam = '';\r\nif ($block-&gt;isLoggedIn()) {\r\n&nbsp;&nbsp;$dataPostParam = sprintf(\" data-post='%s'\", $block-&gt;getPostParams());\r\n}\r\n?&gt;\r\n&lt;li class=\"authorization-link\" data-label=\"&lt;?php echo $block-&gt;escapeHtml(__('or')); ?&gt;\"&gt;\r\n&nbsp;&nbsp;&lt;a &lt;?php \/* @escapeNotVerified *\/ echo $block-&gt;getLinkAttributes(); ?&gt;&lt;?php \/* @escapeNotVerified *\/ echo $dataPostParam; ?&gt;&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php echo $block-&gt;escapeHtml($block-&gt;getLabel()); ?&gt;\r\n&nbsp;&nbsp;&lt;\/a&gt;\r\n&lt;\/li&gt;<\/pre>\n<pre class=\"lang:php decode:true\">\/**\r\n*vendor\/magento\/module-customer\/Block\/Account\/AuthorizationLink.php\r\n*\/\r\nclass AuthorizationLink extends \\Magento\\Framework\\View\\Element\\Html\\Link\r\n{\r\n&hellip;&hellip;&hellip;&hellip;...\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* Is logged in\r\n&nbsp;&nbsp;&nbsp;*\r\n&nbsp;&nbsp;&nbsp;* @return bool\r\n&nbsp;&nbsp;&nbsp;*\/\r\n&hellip;&hellip;&hellip;&hellip;&hellip;...\r\n&nbsp;&nbsp;public function isLoggedIn()\r\n&nbsp;&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $this-&gt;httpContext-&gt;getValue(Context::CONTEXT_AUTH);\r\n&nbsp;&nbsp;}\r\n}<\/pre>\n<p>Blocks also have various types: for generating lists, forms, tables, etc., but the main purpose of blocks is to separate the business logic and the html output.<\/p>\n<p>&nbsp;<\/p>\n<h2><strong><span style=\"color: #000000;\">When to create a new block or a new template<\/span><\/strong><\/h2>\n<p>Whenever you need to change or add the basic functionality of Magento 2, you should use your own blocks or templates, depending on what you need to do. To add new blocks or containers, use the following instructions:&nbsp;referenceBlock, referenceContainer.<\/p>\n<p>The best option is to add new blocks as a separate module, which can be turned on and off without affecting the system as a whole.<\/p>\n<div class=\"module_in_content_container\"><a href=\"https:\/\/store.belvg.com\/layered-navigation.html\" class=\"link_to_module\" target=\"_blank\" rel=\"noopener\"><\/a><div class=\"module_content\"><img src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/07\/magento_ico_1.9_layered_navigation-1.jpg\" width=\"450\" height=\"450\" alt=\"magento_ico_1.9_layered_navigation (1)\" class=\"module_image\" title=\"How Do Magento Blocks and Layouts Work In 2026?\"><div class=\"module_content_part\"><h3 class=\"title\">Layered Navigation<\/h3><p class=\"module_content_text\">Take your online store to the next level with BelVG extensions<\/p><a href=\"https:\/\/store.belvg.com\/layered-navigation.html\" class=\"link_2_to_module\" target=\"_blank\" style=\"display:inline-block\" rel=\"noopener\"><span class=\"read-more\">Download here<\/span><\/a><\/div><\/div><\/div>\n<p>Check out BelVG&rsquo;s quality Magento extensions&nbsp;<a href=\"https:\/\/store.belvg.com\/\" target=\"_blank\" rel=\"noopener\">at our official store<\/a>.<\/p>\n\n","protected":false},"excerpt":{"rendered":"How does html output work in Magento 2","protected":false},"author":42,"featured_media":30779,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_acf_changed":false,"footnotes":""},"categories":[491,389],"tags":[],"class_list":["post-16359","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-magento-2","category-magento2-development","post_format-post-format-image"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"Learn the structure of block templates, root templates, empty.xml &amp; page_layout and how they work in Magento 2\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Aliaksei Hryharenka\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/belvg.com\/blog\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#article\",\"name\":\"How To Work With Magento 2 Blocks in 2026 | BelVG Blog\",\"headline\":\"How Do Magento Blocks and Layouts Work In 2026?\",\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/aleksei-grigorenko#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/image-27.webp\",\"width\":1108,\"height\":590,\"caption\":\"How Do Magento Blocks and Layouts Work\"},\"datePublished\":\"2018-07-26T16:25:39+02:00\",\"dateModified\":\"2026-07-08T13:21:51+02:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#webpage\"},\"articleSection\":\"Magento 2, Magento 2 Development, Image\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"name\":\"Magento 2 Development\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"position\":2,\"name\":\"Magento 2 Development\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#listItem\",\"name\":\"How Do Magento Blocks and Layouts Work In 2026?\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#listItem\",\"position\":3,\"name\":\"How Do Magento Blocks and Layouts Work In 2026?\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"name\":\"Magento 2 Development\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/aleksei-grigorenko#author\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/aleksei-grigorenko\",\"name\":\"Aliaksei Hryharenka\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bc7dc67af8fb059c80185d983bee2fdba6e6500979e4cb118ee4ba0de94c7837?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Aliaksei Hryharenka\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#webpage\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html\",\"name\":\"How To Work With Magento 2 Blocks in 2026 | BelVG Blog\",\"description\":\"Learn the structure of block templates, root templates, empty.xml & page_layout and how they work in Magento 2\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/aleksei-grigorenko#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/aleksei-grigorenko#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/image-27.webp\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html\\\/#mainImage\",\"width\":1108,\"height\":590,\"caption\":\"How Do Magento Blocks and Layouts Work\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#mainImage\"},\"datePublished\":\"2018-07-26T16:25:39+02:00\",\"dateModified\":\"2026-07-08T13:21:51+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"How To Work With Magento 2 Blocks in 2026 | BelVG Blog","description":"Learn the structure of block templates, root templates, empty.xml & page_layout and how they work in Magento 2","canonical_url":"https:\/\/belvg.com\/blog\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/belvg.com\/blog\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#article","name":"How To Work With Magento 2 Blocks in 2026 | BelVG Blog","headline":"How Do Magento Blocks and Layouts Work In 2026?","author":{"@id":"https:\/\/belvg.com\/blog\/author\/aleksei-grigorenko#author"},"publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/07\/image-27.webp","width":1108,"height":590,"caption":"How Do Magento Blocks and Layouts Work"},"datePublished":"2018-07-26T16:25:39+02:00","dateModified":"2026-07-08T13:21:51+02:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/belvg.com\/blog\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#webpage"},"isPartOf":{"@id":"https:\/\/belvg.com\/blog\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#webpage"},"articleSection":"Magento 2, Magento 2 Development, Image"},{"@type":"BreadcrumbList","@id":"https:\/\/belvg.com\/blog\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/belvg.com\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","name":"Magento 2 Development"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","position":2,"name":"Magento 2 Development","item":"https:\/\/belvg.com\/blog\/category\/magento2-development","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#listItem","name":"How Do Magento Blocks and Layouts Work In 2026?"},"previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#listItem","position":3,"name":"How Do Magento Blocks and Layouts Work In 2026?","previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","name":"Magento 2 Development"}}]},{"@type":"Organization","@id":"https:\/\/belvg.com\/blog\/#organization","name":"BelVG Blog","description":"Magento and Prestashop articles","url":"https:\/\/belvg.com\/blog\/"},{"@type":"Person","@id":"https:\/\/belvg.com\/blog\/author\/aleksei-grigorenko#author","url":"https:\/\/belvg.com\/blog\/author\/aleksei-grigorenko","name":"Aliaksei Hryharenka","image":{"@type":"ImageObject","@id":"https:\/\/belvg.com\/blog\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/bc7dc67af8fb059c80185d983bee2fdba6e6500979e4cb118ee4ba0de94c7837?s=96&d=mm&r=g","width":96,"height":96,"caption":"Aliaksei Hryharenka"}},{"@type":"WebPage","@id":"https:\/\/belvg.com\/blog\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#webpage","url":"https:\/\/belvg.com\/blog\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html","name":"How To Work With Magento 2 Blocks in 2026 | BelVG Blog","description":"Learn the structure of block templates, root templates, empty.xml & page_layout and how they work in Magento 2","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/belvg.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/belvg.com\/blog\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#breadcrumblist"},"author":{"@id":"https:\/\/belvg.com\/blog\/author\/aleksei-grigorenko#author"},"creator":{"@id":"https:\/\/belvg.com\/blog\/author\/aleksei-grigorenko#author"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/07\/image-27.webp","@id":"https:\/\/belvg.com\/blog\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html\/#mainImage","width":1108,"height":590,"caption":"How Do Magento Blocks and Layouts Work"},"primaryImageOfPage":{"@id":"https:\/\/belvg.com\/blog\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html#mainImage"},"datePublished":"2018-07-26T16:25:39+02:00","dateModified":"2026-07-08T13:21:51+02:00"},{"@type":"WebSite","@id":"https:\/\/belvg.com\/blog\/#website","url":"https:\/\/belvg.com\/blog\/","name":"BelVG Blog","description":"Magento and Prestashop articles","inLanguage":"en-US","publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"}}]}},"aioseo_meta_data":{"post_id":"16359","title":"How To Work With Magento 2 Blocks in 2026 | #site_title","description":"Learn the structure of block templates, root templates, empty.xml &amp; page_layout and how they work in Magento 2","keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-11-03 18:37:06","updated":"2026-11-03 18:37:06"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/category\/magento2-development\" title=\"Magento 2 Development\">Magento 2 Development<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow Do Magento Blocks and Layouts Work In 2026?\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/belvg.com\/blog\/"},{"label":"Magento 2 Development","link":"https:\/\/belvg.com\/blog\/category\/magento2-development"},{"label":"How Do Magento Blocks and Layouts Work In 2026?","link":"https:\/\/belvg.com\/blog\/working-with-block-templates-root-templates-empty-xml-and-page_layout-in-m2.html"}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/16359","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/comments?post=16359"}],"version-history":[{"count":3,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/16359\/revisions"}],"predecessor-version":[{"id":30781,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/16359\/revisions\/30781"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media\/30779"}],"wp:attachment":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media?parent=16359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/categories?post=16359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/tags?post=16359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}