Edit: Slightly better understood

If I attempt to load my block from inside the module's default.xml it doesn't work, if I load it from Magento_Theme's default.xml layout file then it appears on the page?

Edit: I have it working but don't know why.

It depends on the container. If I reference a container and then add my block inside that it displays.

If I place my block just in it does not display.

All of the following paths are in the app/code directory.

I simply want to display my template file on the page, and it isn't showing. The module is enabled, cache cleared, grunt clean... still nothing.

Template: Website/Product/view/frontend/templates/phtml/header.phtml
Template file content:

         <p>Testing, testing, testing</p>

Layout file: Website/Product/view/frontend/layout/default.xml
Layout file content:

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


<?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="Website_Product" setup_version="2.0.0">
            <module name="Magento_Catalog"/>




Things I've tried:

replacing template="phtml/header.phtml" with template="Website_Product::phtml/header.phtml" in layout.xml

  • What if you replace template="phtml/header.phtml" with template="Elcometer_Product::phtml/header.phtml" ? Commented Jun 17, 2016 at 8:40
  • I tried that too. I'll try again now with grunt clean and bin/magento cache:flush Commented Jun 17, 2016 at 8:43
  • Yes, still nothing shows. I have another module that I wrote that works fine. The only difference is that module is added from another module/my theme's layout file. Commented Jun 17, 2016 at 8:46
  • any error are generate inside log file? Commented Jun 17, 2016 at 8:55
  • Merged layout errors, nothing relevant. Commented Jun 17, 2016 at 9:00

2 Answers 2


When trying to use the layouts that have been previously created by Magento, you have to first decide if you are trying to edit the layout of a page, or the content within it.

For example, within the Magento/Theme/view/frontend/layout/default.xml file, you will see code such as this:

<referenceContainer name="main">
            <container name="content.top" label="Main Content Top"/>
            <container name="content" label="Main Content Area"/>
            <container name="content.aside" label="Main Content Aside"/>
            <container name="content.bottom" label="Main Content Bottom"/>

The containers allow you to add content within one of these area's within the page. So for example, if we wanted to add our own custom content to the "content" block (often used in Magento1) we could do so by doing something like the following in our own layout file:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-right" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="content">
            <block class="Namespace\Module\Block\BlockName" name="custom_name" template="Namespace_Module::template.phtml"/>

The reason as to why it may not have been showing previously, could be because of one of the following:

  1. A container for your block to be shown
  2. An incorrect path to the template being used
  3. An incorrect handle for the file name (not in your case but might be useful for others) i.e. catalog_product_view.xml could be used to add content to a product page

Your default.xml code as below:

<?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">
        <block class="Magento\Framework\View\Element\Template" name="elcoproduct" template="Elcometer_Product::phtml/header.phtml"/>
  • I have that. It doesn't work. Commented Jun 17, 2016 at 8:51
  • Have you run command php bin/magento setup:upgrade? Commented Jun 17, 2016 at 8:55
  • Tried that. Makes no difference. Commented Jun 17, 2016 at 9:04
  • setup:upgrade has nothing to do with missing blocks and will throw an exception if the database is not up to date with migrations anyway. Commented Aug 11, 2017 at 11:06

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.