2

How to add custom meta tag in head tag of page-layout-2columns-left

custom meta tag l want to add is

<meta property="og:image" itemprop="image" content="url"/>

P.S.

I want this url to be dynamic which change on page to page.

2 Answers 2

2

You can do it by update page_layout/2columns-left.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">
  <head>
    <meta property="og:image" itemprop="image" content="url"/>
  </head>
.......
.......
</layout>
1
  • i had updated question again. i wanted this url to be dynamic for page to page May 18, 2018 at 14:23
1

You can use

head.additional
and add a new block with a custom class and custom phtml

<referenceBlock name="head.additional">
    <block class="Vendor\Module\Block\CustomHead" name="custom_head" template="Vendor_Module::custom_head.phtml"/>
</referenceBlock>
2
  • then what will be the content of customhead.php and phtml file
    – Pramod
    Aug 10, 2020 at 6:56
  • you will be able to add your meta tags as in the question
    – Ahmed Atef
    Aug 10, 2020 at 20:36

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.