How To Add Custom Meta Tag In Product View Page In Magento 2

In this post, I will guide you on How To Add Custom Meta Tag In Product View Page In Magento 2. Add many custom meta tags to the product view page to optimize SEO for the product.

With the below method, you can add as many meta tags as you want in just one code paragraph without having to create many custom blocks and you can add them to the default block.

What Is Meta Tag?

Meta tags are tags used in HTML and XHTML documents to provide structured metadata about a web page. They are part of a website’s tag and they can be read by search engines and web crawlers, so they can potentially help boost SEO.

Steps To Add Custom Meta Tag In Product View Page In Magento 2

1. Open the catalog_product_view.xml file by following the link below:


2. And add the following code:

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceBlock name="head.additional">
            <block class="Magento\Catalog\Block\Product\View" name="meta_type_name" template="Magento_Catalog::product/view/magetop_custom_meta_tags.phtml" />

3. Create magetop_custom_meta_tags.phtml file in the following path:


4. Add the following code:

<meta property="og:your_custom_meta_tag_name" content="your_meta_tag_content" />

Then, run deploy static content, flush cache command and see the result:

php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

Follow us for the more helpful posts!

We hope this is a useful post for you.

You can read more useful posts like How To Get Site Key And Secret Key From Google reCAPTCHA.

Thank you for reading!

4.7 3 votes
Article Rating

Aaron LX

Aaron is a passionate writer, crazy about shopping, eCommerce and trends. Besides his outstanding research skills and a positive mind, Aaron eagerly shares his experience with the readers.

Leave a Reply or put your Question here

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x