Redeem Now
Read More
Read now
Menu Close
    Start a Project Request quote Reading list Switch to dark mode
    magento-hyperlocal-marketplace-guide

    How to show a block content on homepage with layout file in Magento 2

    Today we will learn how can we call a block or show a template file on homepage with a layout file.

    The main question here is what is the layout file for homepage and the answer is cms_index_index.xml.

     

    So first create a cms_index_index.xml file under Webkul/HelloWorld/view/frontend/layout/ folder


     

    Then create a HomePage.php under Webkul/HelloWorld/Block/ folder


     

    After that create a homepage.phtml file under Webkul/HelloWorld/view/frontend/templates/ folder


     

    Home Page view

     

    There is one more way to show a block on homepage, you can check it here Call Phtml file on CMS Page – Magento2.

     

    Happy coding 🙂 Feel free to comment if you have any issue.

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close