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.
FAQ
Question "What is a JSON-LD schema generator and do I need one for my Shopify store?",
Answer A JSON-LD schema generator creates structured data markup - a small block of code that tells Google exactly what your page contains, such as a product, review, FAQ, or business. For Shopify stores, adding JSON-LD schema is one of the highest-leverage SEO improvements you can make. It enables rich results in Google Search - star ratings, price snippets, FAQ dropdowns - that appear before anyone clicks your listing. This generator builds clean, Google-compliant schema without any coding required.
Question "What is the difference between a combined @graph schema and separate script blocks?",
Answer A combined @graph block merges multiple schema types (Product, BreadcrumbList, Organization, etc.) into a single script tag. This reduces duplicate code, improves your page's text-to-script ratio, and keeps things tidy for Google to parse. Separate script blocks output each schema type as its own individual script tag. Both are valid - the @graph approach is generally preferred for cleaner implementation. Note that FAQPage must always be its own standalone script block regardless of which mode you choose.
Question "Should I nest AggregateRating and Review inside my Product schema?",
Answer "Yes - nesting AggregateRating and Review inside your Product schema is the correct and Google-preferred approach for rich result eligibility. When nested, the rating automatically references the product, which is exactly what Google expects for star rating snippets in search results. The only exception is if your Shopify review app (such as Judge.me, Yotpo, or Okendo) already outputs its own review schema - in that case, uncheck the nesting toggle in this generator to avoid duplicate schema conflicts.
Question "Why does FAQPage always output as a standalone script block?",
Answer Google only allows one FAQPage schema per page. If FAQPage were merged into your main @graph block alongside other schemas, it could create conflicts or be ignored entirely. By always outputting FAQPage as its own separate script tag, this generator ensures you can manage it independently - and that Google can reliably detect and display your FAQ dropdowns in search results. Never add more than one FAQPage block to a single page.
Question "Where do I paste the generated JSON-LD schema in my Shopify store?",
Answer "The correct file depends on the page type you are optimising. Product schema goes into product.liquid, collection schema into collection.liquid, and homepage schemas (WebSite, Organization) into index.liquid or theme.liquid. The easiest method for non-developers is to use a Custom Liquid block inside the Shopify theme editor - navigate to the correct page template, add a Custom Liquid section, and paste the full script tag. For dynamic data that updates automatically with your products, use the code editor with Liquid variables as shown in the implementation guide on this page.
Question "Will adding JSON-LD schema guarantee rich results in Google Search?",
Answer "Adding valid JSON-LD schema makes your pages eligible for rich results, but Google does not guarantee them. Google decides whether to display rich results based on several factors including schema validity, whether the data matches visible page content, your site's overall quality signals, and the specific search query. To maximise your chances: ensure all required fields are filled (price and image are mandatory for Product rich results), validate using Google's Rich Results Test, and only include schema for content that is actually visible on the page.
Question "Can I add schema to every page using theme.liquid in Shopify?",
Answer "Only site-wide schemas like WebSite and Organization should be added to theme.liquid, as these apply to every page and that is appropriate. Page-specific schemas - Product, FAQPage, CollectionPage, Article - must never be added to theme.liquid, because they will load on every page of your store. Google seeing product schema on your contact page or homepage is a guideline violation that can result in penalties or schema being ignored entirely. Always add page-specific schema to the matching template file.
Question "How do I test my JSON-LD schema to make sure it is working correctly?",
Answer "There are three tools to use. First, Google's Rich Results Test (search.google.com/test/rich-results) - paste your live page URL to see which rich result types are detected and any errors flagged. Second, the Schema.org Validator (validator.schema.org) for a broader structural check that catches type errors and missing required properties. Third, Google Search Console under Search Appearance ? Rich Results, which shows real-world eligibility across your whole store after Google has crawled your pages. You can also run the Rich Results Test on a Shopify theme preview URL before publishing to validate changes before they go live.