In Magento 2, is there any solution to creating a custom layout XML file for custom cms page?

I want to add XML code and CSS and Js only for my custom cms page.

I know about there is one field available at admin side. But, XML code is the little bit large. So, it's not a better way.

Can anyone guide me how to create it?


4 Answers 4


You can create a custom CMS page layout file by using this below way.

File name should be like this :

cms_page_view_selectable_<CMS Page Identifier>_<Layout Update Name>.xml

=> For eg : If your cms page identifier is customhome, then file name should be cms_page_view_selectable_customhome_customhomelayout.xml

https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/xml-manage.html search : For CMS Pages:

<?xml version="1.0"?>
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <!-- Add your css and js file tag here-->   
            <!-- Add your reference container, ref block etc. here -->
  • It's not working.
    – Jayesh
    Commented Oct 22, 2018 at 19:12
  • Can you please tell me any error log generate or? Commented Oct 22, 2018 at 19:15
  • 1
    How do I find my "custom cms page identifier"?
    – br4nnigan
    Commented Feb 27, 2020 at 17:42
  • 2
    @br4nnigan, it's page's url key Commented Sep 7, 2020 at 15:00
  • 1
    To add to this, the xml file you create should be added to the Magento_Cms/layout directory within your theme Commented Jan 25, 2021 at 0:29


<?xml version="1.0"?>
<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="page.wrapper">
        <referenceContainer name="header.container" htmlClass="header" />
        <referenceContainer name="main.content" htmlClass="main-content" />


<?xml version="1.0"?>
<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
    <layout id="column-full">
        <label translate="true">Column Full</label>

Now you can use layout="column-full" in your XML file or you can select "Column Full" in CMS page > Layout Dropdown.

Hope it helps.

  • It's not working for me :(
    – Jayesh
    Commented Oct 22, 2018 at 19:04
  • I want to create in my custom module. not in theme
    – Jayesh
    Commented Oct 22, 2018 at 19:13
  • How can I add custom CSS in the column-full.xml? Commented Nov 12, 2019 at 13:48
  • @RafaelPerozin you can't add custom CSS in head with this. This is page_layout (page_layout.xsd) and not layout (page_configuration.xsd). Technically you can add custom css in body with this. But the question is custom layout XML file for custom cms page. Which is completely different thing from this answer.
    – izzulmakin
    Commented Oct 18, 2022 at 8:01

You can create custom page XML layout file within your custom theme at:


I have a CMS page with URL key corporate, create following file worked


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.