0

I need to add different meta data for different page layouts, i've tried to do it like this:

    <referenceBlock name="head.additional">
        <block class="Magento\Framework\View\Element\Text" name="meta_og">
            <action method="setText">
                <argument translate="true" name="meta_og" xsi:type="string">
                    <![CDATA[<meta property="og:url" content="stuff.ccom" />]]>
            </action>
        </block>
    </referenceBlock>

but its only working on a normal layout (like default.xml)

How can I use this to add meta for page layouts? (layout/page_layout/test.xml)

Big thanks!

1

You can't do this inside page layouts as they are only supposed to be used for wireframing the page (hence why blocks aren't allowed either, only containers). The only supported tags are:

<container>
<referenceContainer>
<move>
<update>

See the page layout instructions for more info.

  • Thanks for the quick answer, do you know any way to add custom meta data to each page? – qvasz Apr 17 '18 at 14:31
  • If it needs to go on every page you should use default.xml, if it needs to be only on certain pages you'll need to add it to those layout handles such as catalog_product_view.xml. – Ben Crook Apr 17 '18 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.