I'm totally new at Magento 2.
I want to add content to home page.

This is my code:


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Vendor_Module" setup_version="1.0.0" schema_version="1.0.0">




<h1>Home page extra content</h1>

What are next steps that I should do to to make heading appear in home page?

  • 1
    why you have to create custom modules? from admin. Content>Pages> and find out your home page and put the content section
    – Amit Bera
    Feb 19, 2019 at 11:46
  • I want to use modules, because later I'm gonna add some data to them that can't be added using admin page. I want to understand how to do it with code.
    – Rufus
    Feb 19, 2019 at 12:28

2 Answers 2


There are a number of ways to do this but you probably don't need a custom module.

Assuming you need to include content from a phtml file you can simply add something like this into the Design > Layout Update XML section of the Homepage through the admin

<referenceContainer name="header.container">
        <block class="Magento\Framework\View\Element\Template" name="your_block_name" template="Magento_Theme::html/header/your_content.phtml">

This would then look to load a your_content.phtml file from YOUR_THEME_PATH/Magento_Theme/templates/html/header/ and add it to the header container.

If you just wanted static content you can do this through the admin without any coding :

  • Setup a Static Block ( Content > Blocks > Add New Block )
  • Setup a Widget ( Content > Widgets > Add New )
  • Specify Widget type as CMS Static Block
  • Specify Layout Updates including Page and Container where it should show
  • Chose your Block froms step 1

refer this link https://www.mageplaza.com/devdocs/magento-2-create-cms-pages-programmatically.html through this you can create cms page and can add content to home page


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.