Adding JSON-LD Schema to Shopify - Implementation Guide
How to add structured data scripts to your Shopify theme templates using Liquid code blocks
ⓘThis guide assumes you've already generated your JSON-LD using the Schema Generator above. The steps below cover how to get that code into your live Shopify store - safely, cleanly, and in the right place.
1Which template file to edit
Each page type in Shopify has its own Liquid template. Add your schema to the template that matches the page you're optimising - not globally to every page.
product.liquid
- Product schema
- AggregateRating (nested)
- Review (nested)
- BreadcrumbList
📚 collection.liquid
- CollectionPage schema
- BreadcrumbList
- Organization
🏠 index.liquid
- WebSite schema
- Organization
- LocalBusiness
📄 article.liquid
- Article / BlogPosting
- Person (author)
- BreadcrumbList
👥 page.liquid
- FAQPage (standalone)
- Person
- LocalBusiness
🏭 theme.liquid
- WebSite (site-wide)
- Organization (site-wide)
- Avoid adding page-specific schema here
⚠Don't add product or FAQ schema to theme.liquid - it loads on every page. Google will see product schema on your contact page, homepage, etc. and may penalise or ignore it. Page-specific schemas belong in page-specific templates.
2Method A - Theme editor (no code, easiest)
Works in most modern Shopify themes. Best for adding static, hardcoded JSON-LD to a single page or template section.
1
Open Online Store → Themes
From your Shopify admin, go to Online Store → Themes and click Customize on your active theme.
2
Navigate to the correct page template
Use the page type dropdown at the top of the editor (it defaults to Homepage). Switch to Products, Collections, or whichever template you need.
3
Add a Custom Liquid block
In the left panel, click Add section (or Add block inside an existing section). Search for Custom Liquid and add it. Position it at the bottom of the template - it won't affect visible layout.
4
Paste your JSON-LD script
Copy the output from the Schema Generator and paste it directly into the Custom Liquid text box. The full <script type="application/ld+json">...</script> block goes in as-is.
⚠Custom Liquid in the theme editor is static. If you paste a hardcoded price or product name, it won't update when the product changes. For dynamic data, use Method B (code editor with Liquid variables) below.
3Method B - Code editor with Liquid variables (recommended for product pages)
This method makes your schema dynamic - product name, price, image, and availability pull directly from Shopify's data objects so the schema always stays in sync with your store.
1
Go to Edit Code
In your Shopify admin: Online Store → Themes → ... (Actions) → Edit code.
2
Find your template file
In the left file tree, open the Templates folder. Click the file you need - e.g. product.liquid or product.json (in newer themes). For JSON-based themes, you'll create a section snippet instead - see step 3b below.
3
Paste your schema at the bottom of the file
Scroll to the bottom of the template file. Paste your schema block after all existing content. For cleanliness, wrap it in a Liquid comment so it's easy to find later.
Dynamic product schema - copy & adapt
Replace the static values from the generator with these Liquid variable equivalents. Shopify fills them in automatically at render time.
{% comment %} JSON-LD Product Schema - generated via Schema Generator {% endcomment %}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "Product",
"name": {{ product.title | json }},
"description": {{ product.description | strip_html | json }},
"image": {{ product.featured_image | img_url: 'master' | prepend: 'https:' | json }},
"url": {{ shop.url }}{{ product.url }},
"sku": {{ product.selected_or_first_available_variant.sku | json }},
"brand": {
"@type": "Brand",
"name": {{ product.vendor | json }}
},
"offers": {
"@type": "Offer",
"price": {{ product.price | money_without_currency | remove: ',' }},
"priceCurrency": {{ cart.currency.iso_code | json }},
"availability": {% if product.available %}"https://schema.org/InStock"{% else %}"https://schema.org/OutOfStock"{% endif %},
"url": {{ shop.url }}{{ product.url }}
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4.8",
"reviewCount": "124"
}
},
{
"@type": "BreadcrumbList",
"itemListElement": [
{ "@type": "ListItem", "position": 1, "name": "Home", "item": {{ shop.url | json }} },
{ "@type": "ListItem", "position": 2, "name": {{ product.type | json }}, "item": "{{ shop.url }}/collections/{{ product.type | handleize }}" },
{ "@type": "ListItem", "position": 3, "name": {{ product.title | json }}, "item": "{{ shop.url }}{{ product.url }}" }
]
}
]
}
</script>
⚠AggregateRating note: Shopify doesn't expose review counts natively in Liquid. If you use a review app (Judge.me, Yotpo, Okendo), check their docs - most provide their own Liquid objects like product.metafields.reviews.rating. Replace the hardcoded values above with those, or remove the aggregateRating block if your review app outputs its own schema.
Organisation / WebSite schema for the homepage (static - goes in theme.liquid or index.liquid)
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "WebSite",
"name": {{ shop.name | json }},
"url": {{ shop.url | json }},
"potentialAction": {
"@type": "SearchAction",
"target": {
"@type": "EntryPoint",
"urlTemplate": "{{ shop.url }}/search?q={search_term_string}"
},
"query-input": "required name=search_term_string"
}
},
{
"@type": "Organization",
"name": {{ shop.name | json }},
"url": {{ shop.url | json }},
"logo": {{ shop.brand.logo | image_url: width: 600 | prepend: 'https:' | json }},
"email": {{ shop.email | json }},
"sameAs": [
"https://www.facebook.com/yourpage",
"https://www.instagram.com/yourhandle"
]
}
]
}
</script>
4Method C - Creating a standalone schema snippet
For online store 2.0 themes (Dawn, Refresh, etc.) with JSON-based templates, the cleanest approach is a dedicated Liquid snippet that you include wherever needed.
1
Create a new snippet file
In Edit Code, open the Snippets folder and click Add a new snippet. Name it something clear like schema-product or schema-faq.
2
Paste your schema into the snippet
Drop your full <script type="application/ld+json"> block (with Liquid variables if needed) into the new snippet file and save.
3
Include the snippet in your template
In product.liquid (or whatever template applies), add one line at the bottom to pull in the snippet:
{% comment %} Schema markup {% endcomment %}
{% render 'schema-product' %}
{% render 'schema-faq' %}
This keeps your template files clean and lets you update schema across the whole store by editing one snippet file - without touching individual templates.
5Where to place the script tag
📌 Placement rules
Google can read JSON-LD anywhere in the page - <head> or <body>. However, for Shopify specifically:
- Product / Article / Collection schema - place at the bottom of the template body. Easier to maintain and won't delay head rendering.
- WebSite / Organization - can go in <head> via theme.liquid since they're site-wide and static.
- FAQPage - place near the FAQ content on the page, or at the bottom of the template. Keep it as a separate <script> block - never merge into your main @graph.
- Never place schema inside a conditional that hides it - e.g. inside {% if template == 'product' %} blocks that may not render. Google needs to be able to read it reliably on every page load.
6Testing & validation
1
Google Rich Results Test
Paste your live page URL (after saving and publishing) into search.google.com/test/rich-results. It shows exactly which rich result types are detected and flags any errors or warnings.
2
Schema.org validator
validator.schema.org gives a broader structural check. Useful for catching type errors and missing required properties that Google's tool might not flag clearly.
3
Google Search Console - Rich Results report
After a few days of Google crawling, check Search Console under Search appearance → Rich results. This shows real-world eligibility across your whole store - not just a single URL.
✓Pro tip: Use the Rich Results Test on your staging/preview URL before publishing. Shopify theme previews are accessible to Google's testing tool - you can validate before going live.