Placing a Template Block with Magento 2 Layout XML

Placing a Template Block with Magento 2 Layout XML

In Magento 2 most page content is added through layout XML. A generic template block is the simplest way to render your own .phtml file in a chosen container.

Example

<block class="Magento\Framework\View\Element\Template" name="store.settings" group="navigation-sections" template="Magento_Theme::html/container.phtml">

Put this in a layout file inside your theme or module, point template at your file, then flush the layout cache to see it.

Need a second pair of eyes on this? Our team handles Magento development every week. See how we can help.

Keep reading

Related articles

All articles

Need a hand?

Stuck on something similar?
We can fix it with you.

Send us the problem. A senior developer reads every message and replies within one working day.