I want to know if is possible to create different layouts for each page.
In my Magento_Theme/layout/default.xml I have the copy of the Magento/Theme/view/frontend/layout/default.xml and I want to add this block:

<referenceContainer name="head.components">
    <block class="Magento\Framework\View\Element\Template" name="head.changer" template="Magento_Theme::head-changer.phtml" before="-"/>

But I want this to be applied only in my our-services.phtml page.
Can someone tell me if this is possible, and if it is how can I do it?

1 Answer 1


If the page you are referring to is a CMS Page this layout adjustment (quoted by you) can be added to "Layout Update" field while editing the CMS Page from Admin panel.

If the page has it's own controller, the block should be added to layout file with module_controller_action.xml name corresponding to action that is rendering the page.

  • how can I create an own controller to a specific page?
    – RuiVBoas
    Mar 16, 2017 at 16:36
  • You can create a page using a controller, not vise-a-verse. CMS Pages are handled by Magento\Cms\Controller\Index\Index controller and cms_index_index.xml layout, so the only option here is adding layout update from admin panel (or installing it to db). Mar 16, 2017 at 16:48

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.