How to Add Structured Data and Rich Snippets in Magento 2

Structured data helps search engines understand the content of your pages and can enable rich results (enhanced search listings) in Google, Bing, and other search engines. For Magento stores, structured data typically covers products, breadcrumbs, reviews, and organization information.

What Structured Data Does

Structured data uses a standardized vocabulary (Schema.org) to describe page content in a machine-readable format. When search engines parse structured data, they may display enhanced search results such as:

  • Product rich results: Price, availability, review stars directly in search listings
  • Breadcrumb trails: Navigational path shown below the page title in search results
  • Review snippets: Star ratings and review counts
  • FAQ results: Expandable question-and-answer sections

An Important Caveat

Valid structured data markup does not guarantee that Google will display rich results. Google's rich results display is discretionary -- their algorithms decide when and whether to show enhanced listings based on quality signals, page authority, and other factors.

The most common reason for not seeing rich results is not a markup error but simply Google's crawl timing. Google does not re-crawl all pages at the same frequency. New or updated structured data may take days or weeks to be processed, and even then, Google may choose not to display rich results for every page.

JSON-LD Format

The recommended format for structured data in Magento 2 is JSON-LD (JavaScript Object Notation for Linked Data). JSON-LD is placed in a <script> tag in the page <head> and does not interfere with the visible HTML.

Product Schema

{
  "@context": "https://schema.org",
  "@type": "Product",
  "name": "Example Product Name",
  "image": "https://example.com/media/catalog/product/image.jpg",
  "description": "Product description text",
  "sku": "PROD-SKU-001",
  "brand": {
    "@type": "Brand",
    "name": "Brand Name"
  },
  "offers": {
    "@type": "Offer",
    "url": "https://example.com/product-url.html",
    "priceCurrency": "USD",
    "price": "49.99",
    "availability": "https://schema.org/InStock",
    "seller": {
      "@type": "Organization",
      "name": "Store Name"
    }
  }
}

Key fields for product schema:

  • name, image, description, sku -- basic product information
  • offers.price and offers.priceCurrency -- required for price display in search results
  • offers.availability -- use InStock, OutOfStock, or PreOrder
  • brand -- helps Google associate products with brand queries

BreadcrumbList Schema

{
  "@context": "https://schema.org",
  "@type": "BreadcrumbList",
  "itemListElement": [
    {
      "@type": "ListItem",
      "position": 1,
      "name": "Home",
      "item": "https://example.com/"
    },
    {
      "@type": "ListItem",
      "position": 2,
      "name": "Category Name",
      "item": "https://example.com/category.html"
    },
    {
      "@type": "ListItem",
      "position": 3,
      "name": "Product Name",
      "item": "https://example.com/product.html"
    }
  ]
}

AggregateRating and Review Schema

{
  "@context": "https://schema.org",
  "@type": "Product",
  "name": "Example Product",
  "aggregateRating": {
    "@type": "AggregateRating",
    "ratingValue": "4.5",
    "reviewCount": "42",
    "bestRating": "5",
    "worstRating": "1"
  },
  "review": [
    {
      "@type": "Review",
      "author": {
        "@type": "Person",
        "name": "Customer Name"
      },
      "reviewRating": {
        "@type": "Rating",
        "ratingValue": "5"
      },
      "reviewBody": "Great product, fast shipping."
    }
  ]
}

Only include review markup if your store actually collects and displays reviews. Google penalizes sites that show review stars in structured data when the page has no visible reviews.

Testing Structured Data

Google Rich Results Test

Use the Rich Results Test to validate your structured data:

  1. Enter a page URL or paste the HTML code
  2. The tool shows which rich result types are detected and any errors or warnings
  3. Fix any errors (missing required fields, invalid values) and retest

Google Search Console

In Google Search Console → Enhancements, Google reports structured data issues across your entire site, grouped by type (Product, Breadcrumb, FAQ, etc.). Monitor this section for:

  • Errors: Missing required fields, invalid values. These prevent rich results entirely.
  • Warnings: Optional fields missing. Rich results may still display but with reduced information.
  • Valid items: Pages with correctly implemented structured data.

Browser Debugging

View the page source and search for application/ld+json to find the JSON-LD blocks. Validate the JSON syntax and check that dynamic values (price, availability, rating) are populated correctly.

Implementation in Magento

Most Magento SEO extensions (including Mirasvit SEO) generate structured data automatically based on product attributes, categories, and reviews. Check your extension's configuration for:

  • Which schema types are enabled
  • Which product attributes map to which schema properties
  • Whether breadcrumb markup is generated on all pages

If implementing structured data manually, add the JSON-LD script blocks in the page's <head> section via a layout XML file or a custom block/template.

Loading...