How to Add Dynamic Collection Schema in Shopify (Dawn Theme)

Adding structured data (schema) to your Shopify collection pages helps search engines better understand your content and can improve visibility in search results.

In this guide, I’ll show you how to implement a dynamic CollectionPage schema for Shopify’s Dawn theme.


What This Does

  • Adds CollectionPage schema to collection pages
  • Dynamically includes product data
  • Improves SEO and rich result eligibility

Where to Add the Code

  1. Go to Online Store → Themes
  2. Click Edit Code
  3. Open the file:
    sections/main-collection-product-grid.liquid

Placement Options

Paste the schema in one of the following locations:

  • At the bottom of the file
  • OR right after the pagination line:
    {% paginate collection.products by ... %}

Schema Code

{% if collection %}
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "CollectionPage",
  "@id": "{{ shop.url }}{{ collection.url }}#collection",
  "name": "{{ collection.title | escape }}",
  "description": "{{ collection.description | strip_html | escape }}",
  "url": "{{ shop.url }}{{ collection.url }}",
  "mainEntity": {
    "@type": "ItemList",
    "itemListElement": [
      {% for product in collection.products limit: 20 %}
      {
        "@type": "ListItem",
        "item": {
          "@type": "Product",
          "name": "{{ product.title | escape }}",
          "url": "{{ shop.url }}{{ product.url }}",
          "image": "{% if product.featured_image %}https:{{ product.featured_image | img_url: '800x' }}{% endif %}",
          "sku": "{{ product.variants.first.sku | escape }}",
          "offers": {
            "@type": "Offer",
            "priceCurrency": "{{ shop.currency }}",
            "price": "{{ product.price | divided_by: 100.0 }}",
            "availability": "https://schema.org/{% if product.available %}InStock{% else %}OutOfStock{% endif %}",
            "url": "{{ shop.url }}{{ product.url }}"
          }
        }
      }{% unless forloop.last %},{% endunless %}
      {% endfor %}
    ]
  }
}
</script>
{% endif %}

Key Notes

  • Displays up to 20 products in schema (can be adjusted)
  • Automatically pulls:
    • Product name
    • URL
    • Image
    • SKU
    • Price & availability
  • Works dynamically for all collection pages

Testing

After adding the schema:

  • Open a collection page
  • Test using Google Rich Results Test
  • Check for errors or warnings

Conclusion

This implementation is a simple yet powerful way to enhance your Shopify store’s SEO. By adding structured data to collection pages, you make it easier for search engines to understand your product listings.

It’s lightweight, dynamic, and works seamlessly with the Dawn theme.