Magento – Magento 2 : Custom Layout for Static Page Empty Into Frontend

customlayoutmagento2static-content

I've create a custom layout for static page into Magento 2.

app/design/frontend/VENDOR/THEME/Magento_Cms/layouts.xml

<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
    <layout id="customer-service">
        <label translate="true">customer-service</label>
    </layout>
</page_layouts>

app/design/frontend/VENDOR/THEME/Magento_Cms/page_layout/customer-service-layout.xml

<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="content">
</referenceContainer></layout>

Now I can select my layout into Design ->Layout of my Static Page but into my frontend, I have a blank white page.

Information:

  1. It doesn't even work if I put my layout code in the Magento_Theme module
  2. If I select another layout of my page everything works properly.
  3. The frontend page doesn't go to 404 page but an empty page with class cms-page-view page-layout-customer-service in the body tag

Can you help me, please?

Best Answer

Add Code

app/design/frontend/VENDOR/THEME/Magento_Theme/layouts.xml

<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
    <layout id="customer-service">
        <label translate="true">Customer Service</label>
    </layout>
</page_layouts>

Create New File under

app/design/frontend/VENDOR/THEME/Magento_Theme/page_layout/customer-service.xml

<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
    <update handle="empty"/>
    <referenceContainer name="page.wrapper">
        <container name="header.container" as="header_container" label="Page Header Container" htmlTag="header" htmlClass="page-header" before="main.content"/>
        <container name="page.top" as="page_top" label="After Page Header" after="header.container"/>
        <container name="footer-container" as="footer" before="before.body.end" label="Page Footer Container" htmlTag="footer" htmlClass="page-footer"/> 
    </referenceContainer> 
    <referenceContainer name="content">

    </referenceContainer> 
</layout>