How to create custom layout page in Magento 2 ?

It is very common requirement that we need to create a custom page for new campaigns. But the layout of that page is different from the website generic pages layout. Today we gonna learn how to create custom page layout.

Magento have default page payout which are as follows :

  • Empty
  • 1 column
  • 2 columns with left bar
  • 2 columns with right bar
  • 3 columns

Creating custom layout is two steps process :). Here you go!

  1. Create <Vendor>/<Module Name>/view/frontend/layouts.xml file which register custom layout in the Magento
  2. Create <Vendor>/<Module Name>/view/frontend/page_layout/custom.xml file to manage layout of your page.

That’s it. Now you can check this layout in any Content > Elements > Pages > Design section.

custom-layout

 

Magento 2 Associate Developer Certification exam sample question

You’re tasked with investigating a custom page layout declared in MyCompany/MyModule that isn’t loading. You’ve determined that this is the result of your XML configuration.

Which 2 files do you investigate to locate the issue?

  • MyCompany/MyModule/view/frontend/layouts.xml
  • MyCompany/MyModule/view/frontend/layout/page.xml
  • MyCompany/MyModule/view/page_layout/custom.xml
  • MyCompany/MyModule/view/frontend/page_layout/custom.xml

Please comment your answers 😀