2

I have created a custom layout for my homepage, now when I refresh the page I get an empty page (this is good I assume).

I was wondering how do I put in custom content?

let's say I want to created a hero area with a subscribe form in it, how do I go around doing that?

here's my folder structure:

https://i.gyazo.com/91c3a66e809c33e44c087ca3806ada06.png

1

You can follow this guide to create new custom homepage layout: Creating a custom homepage template in Magento2

Recommended way

Login to Admin > CONTENT > Page > choose Homepage

We can add the new content to this page via Layout(Layout Update XML) or directly(Content). This way allows us to manage the Homepage content easily. The homepage is one of the most important pages because customers usually go to this page at the first time. So, this content should be changed easily. For example, for the Black Friday, the Admin can add more content to attract the visitors and don't need an expert developer to do this.

Another way

Update the Homepage content - cms_index_index.xml. For example: app/design/frontend/Vendor/Theme/Magento_Cms/layout/cms_index_index.xml

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block class="Magento\Framework\View\Element\Template" name="default_home_page" template="Magento_Cms::default/home.phtml"/>
        </referenceContainer>
    </body>
</page>

enter image description here

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.