5

I wish to add a custom home page layout in Magento 2.

Dropdown

In Magento 1, it's very simple, i create my module :

<?xml version="1.0"?>
<config>
    <modules>
        <Vendor_Custom>
            <codePool>local</codePool>
            <active>true</active>
        </Vendor_Custom>
    </modules>
</config>

and i create a config.xml

<?xml version="1.0"?>
<config>
    <global>
        <page>
            <layouts>
                <custom_home_page>
                    <label>Custom Home Page</label>
                    <template>page/home.phtml</template>
                </custom_home_page>
            </layouts>
        </page>
    </global>
</config>

It's possible to do something similar in Magento 2?

13

Create layouts.xml following location:

[namespace]/[modulename]/view/frontend/layouts.xml

Content should be

<?xml version="1.0" encoding="UTF-8"?>
<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
    <layout id="homepage">
        <label translate="true">Custom Homepage</label>
    </layout>
</page_layouts>

Create your new custom page layout (ex: homepage.xml) following location:

[namespace]/[modulename]/view/frontend/page_layout/homepage.xml

Content should be well structure page layout. So in your case copy of existing page layout into your custom page layout. All page layouts locate:

magento/module-theme/view/frontend/page_layout/*
7

Use 1st answer for page layout updates, but change locations:

For layouts.xml move it to

app/design/[Theme_Vendor]/[Theme_name]/Magento_Theme/ 
and

For homepage.xml move it to

app/design/[Theme_Vendor]/[Theme_name]/Magento_Theme/page_layout/ 

I've tried 1st answer example but it didn't work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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