Short answer: to add JSON-LD to Shopify by hand, create a snippet in your theme (for example snippets/schema-product.liquid) containing a <script type="application/ld+json"> block, fill it from Liquid objects such as product.title with the json filter so values are escaped correctly, and render it from the product section or from theme.liquid. The alternatives are an app embed (switched on in the theme editor, no code) or an app. Whichever you choose, check first for JSON-LD your theme or apps already output, or you will create duplicates.
How to add schema markup to Shopify: JSON-LD is the method
If you are wondering how to add structured data to Shopify, the answer is the same as for JSON-LD. Schema markup and structured data are the names for the facts; JSON-LD is the format Google recommends for writing them. So to add schema markup in Shopify, you add a JSON-LD block by one of the three routes below. You will also see the format written without the hyphen, as JSON LD; it is the same thing.
How to add structured data to Shopify safely: check what is there first
Almost every Shopify theme already outputs some JSON-LD, and apps often add more. Adding a new block without looking is the most common way stores end up with two or three Product blocks on one page. Before you write a line:
- Test a product page and the home page in Google's Rich Results Test and note every item it detects.
- Search your theme code (Online Store › Themes › Edit code) for
application/ld+jsonandstructured_data. - Check your apps' settings for schema or "rich snippets" options.
If the theme already outputs Product markup, you usually want to improve or replace that block, not add another. Our guide does Shopify add schema automatically? shows what Dawn outputs, and what is JSON-LD? explains the format.
How to add JSON-LD to Shopify: three ways
| Method | How it works | Good for | Watch out for |
|---|---|---|---|
| Theme code | A Liquid snippet with a JSON-LD block, rendered from a template | Full control, no subscription | Lost or duplicated on theme change; needs Liquid knowledge |
| App embed | A theme app extension switched on in the theme editor under App embeds | No code edits; switch off to remove | Must not overlap the theme's own markup |
| App (script) | An app adds JSON-LD with JavaScript after the page loads | Quick set-up | Not in the page source; Google has to render the page to see it |
Shopify's theme app extensions are the method Shopify recommends for apps: the app's code sits outside your theme files, so uninstalling the app removes it cleanly. Our comparison of a JSON-LD generator vs manual schema covers the trade-offs in more depth.
Adding JSON-LD in Shopify theme code
The tidy way to add JSON-LD to Shopify by hand is a snippet per schema type, rendered where it is needed. Always duplicate your theme first (Online Store › Themes › … › Duplicate) and work on the copy.
Where schema code in Shopify themes lives
Before you add anything, it helps to know where existing markup usually sits. In most themes the Organization and WebSite blocks are in layout/theme.liquid or the header section, Product markup is in the main product section (often through the structured_data filter), Article markup is in the main article section, and older themes or apps may have left extra blocks in the snippets folder. Search the code editor for ld+json to find each one.
- In the code editor, under Snippets, add a new snippet such as
schema-product. - Paste in the template below and adjust it.
- Render it. For product pages, add
{% render 'schema-product' %}to your main product section (in Dawn,sections/main-product.liquid), or totheme.liquidinside{% if request.page_type == 'product' %}…{% endif %}. - Preview the copy, test it, then publish.
Always use the json filter. Writing "{{ product.title }}" breaks the moment a title contains a quote mark, which is the commonest cause of unparsable structured data on Shopify. {{ product.title | json }} outputs a correctly quoted and escaped string. See Shopify's json filter documentation.
Shopify JSON-LD template: Product
A starting point for a single Product block. It reads live values from Shopify, so price and stock stay current:
{%- assign v = product.selected_or_first_available_variant -%}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Product",
"@id": {{ canonical_url | append: '#product' | json }},
"name": {{ product.title | json }},
"url": {{ canonical_url | json }},
"image": {{ product.featured_image | image_url: width: 1200 | prepend: 'https:' | json }},
"description": {{ product.description | strip_html | strip_newlines | truncate: 500 | json }},
"sku": {{ v.sku | json }},
{%- if v.barcode != blank %}
"gtin": {{ v.barcode | json }},
{%- endif %}
"brand": { "@type": "Brand", "name": {{ product.vendor | json }} },
"offers": {
"@type": "Offer",
"url": {{ shop.url | append: v.url | json }},
"price": {{ v.price | divided_by: 100.0 | json }},
"priceCurrency": {{ cart.currency.iso_code | json }},
"availability": "https://schema.org/{% if v.available %}InStock{% else %}OutOfStock{% endif %}"
}
}
</script>
Notes: Shopify stores prices in the smallest currency unit, hence divided_by: 100.0. Only output gtin if your barcodes really are GTINs. This template describes one variant; for full variant markup, Shopify's {{ product | structured_data }} outputs a ProductGroup (see ProductGroup schema). Review stars should come from your review app's data, never typed in by hand.
Shopify JSON-LD template: Organization
Organization belongs on the home page. Add this as snippets/schema-organization.liquid and render it from theme.liquid:
{%- if request.page_type == 'index' -%}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
"@id": {{ shop.url | append: '/#organization' | json }},
"name": {{ shop.name | json }},
"url": {{ shop.url | json }},
{%- if settings.logo != blank %}
"logo": {{ settings.logo | image_url: width: 600 | prepend: 'https:' | json }},
{%- endif %}
"sameAs": [
"https://www.instagram.com/yourstore",
"https://www.facebook.com/yourstore"
]
}
</script>
{%- endif -%}
The logo setting name depends on your theme (settings.logo works in Dawn). Replace the sameAs links with your real profiles. If your theme already outputs an Organization block, edit that one instead; two Organization blocks with different details is a common conflict. Our Organization schema post lists the other fields.
Prefer a form to Liquid? Our free schema markup generator builds static JSON-LD for a Product, Organization, LocalBusiness, breadcrumbs or FAQ that you can paste and adapt. Static JSON-LD will not update itself, so for products the Liquid version above is the better base.
The Shopify no code route: app embeds and apps
A JSON-LD generator for Shopify built as an app usually works in one of two ways. With an app embed, the app ships a theme app extension and you switch it on in the theme editor (Customise › App embeds). The markup is rendered with the page, appears in the page source, and disappears when you switch the embed off. Our guide to Shopify theme app extension schema explains how app embeds work in more detail. With a script, the app adds JSON-LD in the browser after the page loads. Google can usually render and read it, but it is invisible in View Source, harder to debug and depends on the script running.
Whichever app you use, the rule is the same as for theme code: one source per schema type. If the app outputs Product markup, the theme's Product block must be switched off or removed. Some apps offer a setting for this; for others you edit the theme. See duplicate Product schema on Shopify.
Duplicates, stale data and other things that go wrong
- Duplicates. A new block added on top of the theme's or an app's. Google sees two Products, sometimes with different prices.
- Hard-coded values. JSON-LD typed in with a fixed price, stock status or rating goes stale the first time anything changes. Markup that does not match the page goes against Google's structured data policies.
- Lost on theme change. Code added to one theme does not move to a new theme. It is easy to switch themes and lose, or double up, your markup.
- Leftover app code. Older apps wrote snippets straight into theme files, and uninstalling them did not remove the code.
- Unescaped text. Quotes or line breaks in titles and descriptions without the
jsonfilter. - Prices with symbols, such as
"£45"instead of a number and apriceCurrency.
Test JSON-LD on Shopify after adding it
After any change, test a few real pages: a product with variants, an out-of-stock product, the home page. Use the Rich Results Test for Google eligibility, or paste a page's source into our JSON-LD checker for a quick look at validity and duplicates. Then watch the Product snippets and Merchant listings reports in Search Console over the following weeks.
Schema Clinic audits around 13 pages at once, including JSON-LD injected by scripts, flags duplicates with the source of each block, and validates against Google's documentation. On Pro it generates linked JSON-LD for Organization, WebSite, Product, Article, BreadcrumbList and CollectionPage with ItemList and deploys it through the "Schema Clinic" app embed, so there is no theme code to maintain. Plans start at $9.99 a month; there is no free plan or trial. See how it works.