I have phtml file at


How can I make it to change homepage?

I have module.xml file and registration.php file as well. Module is installed.

I suppose that I have to make Block and Controller, but can't get it right.

In wich directories and what files I should make that content.phtml file could make changes to homepage?

  • I've given answer and if you require any other information. Please ping here. Thanks – Prathap Gunasekaran Feb 19 '19 at 13:24

In order display simple content in home page it doesn't require Block or Controller instead you follow these steps to display content in home page.

Firstly, you need to change template to templates.


Add cms_index_index.xml in vendor/module/view/frontend/layout/cms_index_index.xml

then add the following code to the 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">
    <referenceContainer name="content">
        <block class="Magento\Framework\View\Element\Template" name="test" template="vendor_module::content.phtml"></block>

and you can locate your content to specific place in home page by adding these parameters to block element.

you may use before="before.body.end" or after="before.body.start or after.body.start" etc..,

If you want to display any dynamic content which loads from database then you require block to load data.

Hope this helps. Peace :)

  • Thank's!!! It really helped! – Rufus Feb 19 '19 at 13:30
  • upvoted ;) But you are missing the closing tag </page> – VishalParkash Oct 22 '20 at 5:47

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.