How to Add Custom Meta tag in Product View Page in Magento 2

How to Add Custom Meta tag in Product View Page in Magento 2

Hello Magento Friends,

I am back with another Magento solution for you. Today’s topic is How to Add Custom Meta tag in Product View Page in Magento 2.

Meta tags provide information about the page to web browsers and search engines. Meta tags are found on the source code of the page. With the help of meta tags, search engines come to know what the page is about.

If you need a custom meta tag for a specific product page in Magento 2, it can be accomplished with the help of the below code. To create a custom meta tag you need not add a custom block, you can use the default block. You can even add as many meta tags as you want.

Let’s start with the Steps on How to Add Custom Meta tag in Product View Page in Magento 2

Steps to Add Custom Meta tag in Product View Page in Magento 2:

Step 1: Go to the below-given path.

app\design\frontend\Themes\Yourtheme\Magento_Catalog\layout\catalog_product_view.xml

Now, add the code as mentioned below

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="head.additional">
            <block class="Magento\Catalog\Block\Product\View" name="meta_type_name" template="Magento_Catalog::product/view/custom_meta_name.phtml" />
        </referenceBlock>
     </body>
</page>

Step 2: Create a file named custom_meta_name.phtml at the following path

app\design\frontend\Themes\Yourtheme\Magento_Catalog\templates\product\view\

Finally, add the below code

<meta property="og:your_custom_tag_name" content="your_custom_value" />

Conclusion:

Accordingly, you can Add a Custom Meta tag to Product View Page in Magento 2. Our SEO Service can help to increase traffic and rankings of your Magento 2 store. For queries, mention it in the comment part. Share with your friends and stay in touch with us! 

Happy Reading!

Previous Article

Top Selling Items on Etsy in 2024

Next Article

The Most Popular Products to Selling on Facebook in 2024

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *

Get Connect With Us

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨