My block is being included twice inside my cms page from my page layout. Here is my code:
# File: theme_dir/Magento_Theme/page_layout/homepage.xml
<?xml version="1.0"?>
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
<update handle="empty"/>
<referenceContainer name="page.wrapper">
<block class="Magento\Framework\View\Element\Template" template="Magento_Theme::homepage.phtml" />
</referenceContainer>
</layout>
# File: theme_dir/Magento_Theme/layouts.xml
<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
<layout id="homepage">
<label translate="true">homepage</label>
</layout>
</page_layouts>
# File: theme_dir/Magento_Theme/templates/hompeage.phtml
<h1>Homepage Content</h1>
Of course, I have also set my home cms page to my homepage template.
When the page loads I see the phtml file included twice. Inspecting the page I see the following:
<div class="page-wrapper">
<main id="maincontent" class="page-main"><a id="contentarea" tabindex="-1"></a>
...
</main>
<h1>Homepage Content</h1><h1>Homepage Content</h1>
I've tried changing name="page.wrapper"
to other references, such as main
, columns
, etc., (note this required using update handle 1column
instead) but the outcome is the same, the content get's included twice.
The closest success I have had is that this does not seem to happen when I use the page layout in a category page.
Is this expected behavior? How to include the block a single time?
Magento 2.1.3 CE