• Home
  • Implementing Product Schema for Shopify with Liquid

    Chris

    Administrator
    Staff member
    In this guide, I’m focusing on helping you to implement product schema for Shopify ( https://schema.org/Product ) using Liquid handles. Structured data, like product schema, is recommended because it helps search engines better understand your eCommerce store’s content.

    Simply put - adding product schema helps make your products more accessible to search engines. It also enhances the chances of your store appearing prominently in search results, driving more traffic and increasing sales.

    The example schema below also includes ratings and reviews; feel free to remove them. However, they do provide SEO benefits, so I suggest leaving them in. In fact, I would suggest implementing what works for you. If you do need any support with implementation, feel free to reach out to me.


    liquid-product.png


    Product schema is a type of structured data that provides detailed information about products to search engines. This information can include product names, descriptions, prices, availability, and reviews. By incorporating product schema into your Shopify storefront, you can improve how your products appear in the organic search results and Google Shopping.

    Step-by-Step Guide

    1. Adding Product Schema in Shopify​

    To add product schema, you'll need to edit your Shopify theme files. Typically, this will involve modifying the product.liquid template.

    1. Access Your Theme Code:
      • Go to your Shopify admin panel.
      • Navigate to Online Store > Themes.
      • Click Actions > Edit code.
    2. Locate the Product Template:
      • Find the product.liquid (this might be named something different in your theme structure. Ask your developers if you don't know) file in the Sections or Templates directory, depending on your theme structure.
    3. Insert the Schema Markup:
      • Add the following JSON-LD schema markup within a <script type="application/ld+json"> tag. This should be ideally placed inside the <head> although it should work anywhere within the file, for example after the closing </body> tag.

    Code:
    <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "Product",
      "name": "{{ product.title | escape }}",
      "image": "{{ product.featured_image | img_url: '500x500' }}",
      "description": "{{ product.description | strip_html | escape }}",
      "sku": "{{ product.sku | escape }}",
      "mpn": "{{ product.id | escape }}",
      "brand": {
        "@type": "Brand",
        "name": "{{ product.vendor | escape }}"
      },
      "offers": {
        "@type": "Offer",
        "url": "{{ shop.url }}{{ product.url }}",
        "priceCurrency": "{{ shop.currency }}",
        "price": "{{ product.price | money_without_currency }}",
        "priceValidUntil": "2024-12-31",
        "itemCondition": "https://schema.org/NewCondition",
        "availability": "{% if product.available %}https://schema.org/InStock{% else %}https://schema.org/OutOfStock{% endif %}",
        "seller": {
          "@type": "Organization",
          "name": "{{ shop.name | escape }}"
        }
      },
      "aggregateRating": {
        "@type": "AggregateRating",
        "ratingValue": "{{ product.metafields.reviews.rating_value | default: '4.5' }}",
        "reviewCount": "{{ product.metafields.reviews.review_count | default: '100' }}"
      },
      "review": [
        {% for review in product.reviews %}
        {
          "@type": "Review",
          "author": {
            "@type": "Person",
            "name": "{{ review.author_name | escape }}"
          },
          "datePublished": "{{ review.date_published | date: '%Y-%m-%d' }}",
          "reviewBody": "{{ review.body | escape }}",
          "reviewRating": {
            "@type": "Rating",
            "ratingValue": "{{ review.rating | escape }}",
            "bestRating": "5",
            "worstRating": "1"
          }
        }{% unless forloop.last %},{% endunless %}
        {% endfor %}
      ]
    }
    </script>

    2. Understanding the Schema Markup​

    The above product schema incorporates the following schema node elements. As mentioned earlier, tweak and test to find out what works best for your Shopify shop.
    • @context: Defines the schema.org context.
    • @type: Specifies the type of structured data, in this case, "Product".
    • name: The product title.
    • image: The product image URL.
    • description: A description of the product.
    • SKU: The product’s stock-keeping unit.
    • mpn: The manufacturer part number.
    • brand: The brand of the product.
    • offers: Details about the product offer, including price and availability.
    • aggregateRating: The average rating of the product.
    • review: An array of individual product reviews.

    3. Save and Test​

    After adding the schema markup, save your changes and test the implementation using Google’s Rich Results Test tool - https://search.google.com/test/rich-results. This will help with validating that your structured data is correctly implemented. The Rich Results Test tool will flag any validation errors. If you're struggling to validate the product schema, you may have made an error within the array. Keep tweaking and testing until it validates.


    Wrapping it up
    Implementing product schema on your Shopify store should enhance your product listings in search results. By using Liquid shortcodes (handles), you can dynamically populate schema markup with your product data, ensuring that your structured data remains accurate and up-to-date.

    After implementing the schema, I recommend monitoring the results in Google Search Console. Regularly checking performance, filter your results to focus on product snippets to see how your enhancements are performing. You can do this by filtering to Performance > Search Appearance > Product Snippets

    Screenshot 2024-06-09 193907.png


    Additionally, keep an eye on the Shopping panel in Google Search Console for errors. This panel can provide insights into how Google views your product data and highlight any discrepancies that might affect your visibility.

    And that's it; I hope you found the advice in this guide useful. If you need Shopify SEO support, reach out to me.
     
    Last edited: