{"id":11953,"date":"2021-01-09T10:45:36","date_gmt":"2021-01-09T05:15:36","guid":{"rendered":"https:\/\/www.hiddentechies.com\/blog\/?p=11953"},"modified":"2021-01-15T16:22:58","modified_gmt":"2021-01-15T10:52:58","slug":"create-custom-page-layout-magento-2","status":"publish","type":"post","link":"https:\/\/www.hiddentechies.com\/blog\/magento\/create-custom-page-layout-magento-2\/","title":{"rendered":"How to Create Custom Page Layout in Magento 2"},"content":{"rendered":"<p>In this post I am going to explain how to create custom page layout in Magento 2.<\/p>\n<p>Magento 2 provides five front-end page layouts as below.<\/p>\n<p>1. Empty<br \/>\n2. 1column<br \/>\n3. 2columns-left<br \/>\n4. 2columns-right<br \/>\n5. 3column<\/p>\n<p>You can find all layouts at below path.<\/p>\n<pre class=\"lang:default decode:true \">vendor\/magento\/module-theme\/view\/base\/page_layout\/<\/pre>\n<p>Sometimes if amount of customization is too much then in this case you can override these layouts or you can different page layout for your page.<\/p>\n<p>So, now we are going to make custom page layout.<\/p>\n<p>First, make file &#8220;custom-layout.xml&#8221; at below path and here we will copy content from &#8220;1column&#8221; layout. It means our new custom layout is extended from &#8220;Empty&#8221; layout.<\/p>\n<p><strong>Path: app\/design\/frontend\/&lt;vendor&gt;\/&lt;your_theme&gt;\/Magento_Theme\/page_layout\/custom-layout.xml<\/strong><\/p>\n<pre class=\"lang:default decode:true \">&lt;?xml version=\"1.0\"?&gt;\r\n\r\n&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    &lt;update handle=\"empty\"\/&gt;\r\n    &lt;referenceContainer name=\"page.wrapper\"&gt;\r\n        &lt;container name=\"header.container\" as=\"header_container\" label=\"Page Header Container\" htmlTag=\"header\" htmlClass=\"page-header\" before=\"main.content\"\/&gt;\r\n        &lt;container name=\"page.top\" as=\"page_top\" label=\"After Page Header\" after=\"header.container\"\/&gt;\r\n        &lt;container name=\"footer-container\" as=\"footer\" before=\"before.body.end\" label=\"Page Footer Container\" htmlTag=\"footer\" htmlClass=\"page-footer\"\/&gt;\r\n    &lt;\/referenceContainer&gt;\r\n&lt;\/layout&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>Next, we need to do declaration in the list of layouts. So you can see this new layout option in all layout drop-downs.<\/p>\n<p>Make the file &#8220;layouts.xml&#8221; at below path and add below code in it.<\/p>\n<p><strong>Path: app\/design\/frontend\/&lt;vendor&gt;\/&lt;your_theme&gt;\/Magento_Theme\/layouts.xml<\/strong><\/p>\n<pre class=\"lang:default decode:true \">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n\r\n&lt;page_layouts xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/PageLayout\/etc\/layouts.xsd\"&gt;\r\n    &lt;layout id=\"custom-layout\"&gt;\r\n        &lt;label translate=\"true\"&gt;Custom Layout&lt;\/label&gt;\r\n    &lt;\/layout&gt;\r\n&lt;\/page_layouts&gt;<\/pre>\n<p>Now, Our new page layout is reday to use.<\/p>\n<p>For example, Here I am going to change the contact page layout.<\/p>\n<p>Make the file &#8220;contact_index_index.xml&#8221; at below path.<\/p>\n<p><strong>Path: app\/design\/frontend\/&lt;vendor&gt;\/&lt;your_theme&gt;\/Magento_Contact\/layout\/contact_index_index.xml<\/strong><\/p>\n<p>The code of the file should like:<\/p>\n<pre class=\"lang:default decode:true \">&lt;page xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" layout=\"custom-layout\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd\"&gt;\r\n    &lt;head&gt;\r\n        &lt;title&gt;Contact Us&lt;\/title&gt;\r\n    &lt;\/head&gt;\r\n&lt;\/page&gt;<\/pre>\n<p>After all changes done, refresh cache and open contact page see your layout changes applied or not.<\/p>\n<div class=\"angwp_12010 _ning_cont _ning_hidden _ning_outer _align_center responsive\" data-size=\"custom\" data-bid=\"12010\" data-aid=\"0\" style=\"max-width:800px; width:100%;height:inherit;\"><div class=\"_ning_label _left\" style=\"\"><\/div><div class=\"_ning_inner\" style=\"\"><a href=\"https:\/\/www.hiddentechies.com\/blog?_dnlink=12010&t=1777091853\" class=\"strack_cli _ning_link\" target=\"_blank\">&nbsp;<\/a><div class=\"_ning_elmt\"><img decoding=\"async\" src=\"https:\/\/www.hiddentechies.com\/blog\/wp-content\/uploads\/angwp\/items\/12010\/Banner-2.png\" \/><\/div><\/div><\/div><div class=\"clear\"><\/div>","protected":false},"excerpt":{"rendered":"<p>In this post I am going to explain how to create custom page layout in Magento 2. Magento 2 provides five front-end page layouts as below. 1. Empty 2. 1column 3. 2columns-left 4. 2columns-right 5. 3column You can find all layouts at below path. vendor\/magento\/module-theme\/view\/base\/page_layout\/ Sometimes if amount of customization is too much then in&#8230; <\/p>\n<div class=\"actions\"><a href=\"https:\/\/www.hiddentechies.com\/blog\/magento\/create-custom-page-layout-magento-2\/\">Continue Reading<\/a><\/div>\n","protected":false},"author":1,"featured_media":12255,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[181,59,2138],"tags":[729,9,10,2153],"_links":{"self":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/11953"}],"collection":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/comments?post=11953"}],"version-history":[{"count":3,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/11953\/revisions"}],"predecessor-version":[{"id":12251,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/11953\/revisions\/12251"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media\/12255"}],"wp:attachment":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media?parent=11953"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/categories?post=11953"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/tags?post=11953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}