I'm trying to create a simple frontend module on Magento 2.3.2, It seems to work, but I see a blank content on frontend.

I have this folder structure


These are the files


<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="MyVendor_MyModule" setup_version="1.0.0"/>


<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route frontName="myurl" id="myurl">
            <module name="MyVendor_MyModule"/>


namespace MyVendor\MyModule\Controller\Index;

class Index extends \Magento\Framework\App\Action\Action
    protected $_pageFactory;

    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Framework\View\Result\PageFactory $pageFactory)
        $this->_pageFactory = $pageFactory;
        return parent::__construct($context);

    public function execute()
        return $this->_pageFactory->create();


namespace MyVendor\MyModule\Block;
class Index extends \Magento\Framework\View\Element\Template{
    public function __construct(\Magento\Framework\View\Element\Template\Context $context)

    public function _prepareLayout()
        return parent::_prepareLayout();


<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <title>My Title</title>
        <referenceContainer name="content">
            <block class="MyVendor\MyModule\Block\Index" name="mymodule_index_index" template="MyVendor_MyModule::homepage.phtml" />


<h2>This is a custom module</h2>

Then I executed this commands

bin/magento setup:upgrade
bin/magento cache:flush
bin/magento cache:clean

Then I go to https://www.example.com/myurl/index/index I can see the theme, but no title and no "This is a custom module"

Any help would be appreciated :)

2 Answers 2


Change the layout from mymodule_index_index.xml to myurl_index_index.xml.

  • Thank you man! You are my life saver :D
    – fmineo
    Mar 30, 2020 at 10:45

the layout file will have name as format: {router_id}_{controller_name}_{action_name}.xml.

You can understand the layout in detail in this Magento topic , and the instruction of a layout structure.

When rendering page, Magento will check the layout file to find the handle for the page and then load Block and Template. We will create a layout handle file for this module:

Change the layout from mymodule_index_index.xml to myurl_index_index.xml.

for better understand please follow the below guide


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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