I'm trying to include a new template block in a CMS page in the admin via layout updates.
Here is the xml:
<block class="Magento\Catalog\Block\Product\View\Description" name="homepage.carousel" template="homepage/carousel.phtml" before="-" />
The carousel template has been added in [theme-folder]/Magento_Theme/templates/homepage/carousel.phtml. Then I run:
bin/magento cache:flush
bin/magento setup:static-content:deploy
No luck, so then I moved the template to [theme-folder]/Magento_Cms/templates/homepage/carousel.phtml. I re-run the above commands but still no luck. Then I changed the CMS page "New Theme" and set it to my custom theme and re-run the above commands and still no luck.
Any suggestions?
Best Answer
The error was that I forgot to wrap the XML inside a
<referenceContainer name="content">
. So the XML should look like this:And the other thing is that you should add the magento module inside the template src E.g:
Kudos for this last part to Ankit Shah