🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Add Schema Markup to Magento 2? (Rich Snippets)

By Sanjay JethvaUpdated on May 07, 2025 7 min read

Magento 2 rich snippets are a winning strategy to improve the pages’ appearance on Google. It helps improve the click-thru rate, ultimately leading to more traffic. 

Here, the schema markup plays an important role. 

In this guide, learn to implement schema markup and get rich snippets in Magento 2.

What is Schema Markup?

Schema markup is a code that contains structured information about the page. It’s present in the page’s HTML code and helps search engines easily understand its contents. Google and other search engines may display this additional information on the search engine result pages through rich snippets.

For example, here’s a rich snippet on Google showing ratings:

Rich snippet on google example

In the above example, the ratings information comes from the schema markup code.

This makes the page more noticeable on the Google.

Yes, the default Magento Luma theme comes with basic schema markup in microdata format.

However, that’s not enough.

For example, the product schema doesn’t have attributes like availability, offer, review, and shipping details.

You can also add additional schema markups to your Magento 2 store and improve SEO

Rich Snippets for Magento 2

Make your store shine on search engines. Includes all important schema markups.

Get Extension

List of Important Schema Markups for Magento 2

There is one specific type of schema that meets all your requirements; there are 100+ schemas available on the internet. However, you only need these 7 schemas for your Magento 2 store. 

Type of Schema MarkupDescription Present in Magento 2?
ProductInforms search engine that your page is related to the products Yes, but not all attributes
Merchant listingMakes the product page eligible for merchant listing across Google’s searchNo
Review snippetInforms about the average rating and number of reviews on the current productYes, but not all attributes
Local businessTell Google about business hours, location, etc.No
Sitelinks search boxDisplays a search box, right under the snippet on Google to search the websiteNo
OrganizationAllows the search engine to structure your store’s information and display it accordinglyNo
BreadcrumbsInforms about the location of a webpage on the website structureYes 

You can view all the schema markup types supported by Google in the Search Gallery.

Method to Implement Schema Markup in Magento 2

In Magento 2, there is no default option to implement schema markup for SEO.

You can either build a custom extension for rich snippets or modify the theme files to hard-code the required schema markups. Both methods require coding proficiency and you’ll need a developer to implement them.

In this tutorial, we’ll add product schema markup to Magento 2 product pages by modifying the theme files.

Step 1: Remove Existing Schema Markup Code

Go to app/design/frontend/[Vendor]/[theme]/Magento_Catalog/layout/ and open the catalog_product_view.xml file.

Remove any code present in the file and save it. 

Step 2: Create the Schema Template PHTML File

Head to PHTML File Directory and go to app/design/frontend/[Vendor]/[theme]/Magento_Catalog/templates/product.

Now, create a product.phtml file and add the schema markup code in PHP.

Here, you can use variables from the product to form the schema markup. For example, here’s the code for product snippet:

<?php
$product = $block->getProduct();
$schemaData = [
    '@context' => 'https://schema.org/',
    '@type' => 'Product',
    'name' => $product->getName(),
    'image' => $product->getImageUrl(),
    'description' => $product->getShortDescription(),
    'sku' => $product->getSku(),
    'offers' => [
        '@type' => 'Offer',
        'price' => $product->getPrice(),
        'priceCurrency' => 'USD',
        'availability' => 'https://schema.org/InStock'
    ]
];
?>
<script type="application/ld+json">
    <?= json_encode($schemaData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); ?>
</script>

Note: You can make changes as per your schema requirement. 

Save the file. Now, run the following commands in the root directory to apply the changes:

  • bin/magento setup:upgrade
  • bin/magento setup:static-content:deploy
  • bin/magento cache:clean

The schema markup will be added to the product pages in your Magento 2 store.

Step 3: Test Schema Markup Implementation 

Go to Google Rich Results Test and enter the product page URL to test. In case of successful implementation, the valid items will be displayed in the rich results test.

You can also find any errors or warnings in the schema markup implementation through this.

Test schema markup implementation in google rich result test

You can also monitor the health of structured data on your site in Google Search Console (GSC). You can find information about valid and invalid structured data on your site in the Shopping and Enhancements tab.

Health and structured data on your website in google search console

That’s how you can add schema markup to your Magento 2 store and increase the chances for SEO-rich snippets on SERP.

Codless Ways to Add Rich Snippets to Magento 2

The Meetanshi Magento 2 Rich Snippets extension is the easiest way to add schema to your store without a piece of code.

All you need to do is:

Step 1: Enable the extension from the backend

Step 2: Configure a schema of your choice. 

You can configure: Product schema markup, merchant listing, breadcrumbs, site search box, add brand logo & name, local listing, and social meta tags (bonus). 

For example, if you want a website name schema, simply configure these two settings:

  • Status: Enable the schema markup.
  • Website Name: Enter your website name (e.g., Meetanshi)  
Website name schema by Meetanshi

And click Save

The search engines will show your website name, which helps to improve brand visibility and CTR. 

Meetanshi Website Name Schema

Using the Magento 2 rich snippets extension:

  • You can add multiple rich snippets at once
  • With the configuration setting, there is no need to code
  • Add social media tags to maintain brand consistency over all social media platforms 
Rich Snippets for Magento 2

Make your store shine on search engines. Includes all important schema markups.

Get Extension

Frequently Asked Questions 

How to Fix Unparsable Structured Data in Magento 2?

You might have missed adding a double quote, a single comma, or opening or closing brackets. Check the formatting and re-test to confirm if the issue is resolved.

What is Magento 2 Product Schema?

A Magento 2 product schema tells search engines how your product is related to the page. This helps search engines display product details more effectively. 

How Do I Add Rich Snippets in Magento 2?

Here is a simple way to add rich snippets in your Magento 2:

  • Step 1: Add JSON-LD structured data to the product.phtml template file.
  • Step 2: Head to catalog_product_view.xml for edits if needed in schema markup. 
  • Step 3: Run bin/magento setup:static-content:deploy and bin/magento cache:clean to apply updates.
  • Lastly, use Google’s Rich Results Test to verify the implementation.

Enhance Your Magento 2 SEO with Rich Snippets

Adding schema markup to Magento 2 is an effective way to grab a higher ranking and improve your CTR. 

Using the above steps, you can create schemas and increase your chances of getting rich snippets for your Magento 2 store.

Rich Snippets for Magento 2

Make your store shine on search engines. Includes all important schema markups.

Get Extension
Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.