support@schemaclinic.com Free JSON-LD checker Free schema generator Shopify App Store
Schema guide

How to add schema markup (JSON-LD) to Shopify

There are three ways to get JSON-LD onto a Shopify store: write it into the theme, switch on an app embed, or let an app inject it. This guide shows each, with a copyable Shopify JSON-LD template for Product and Organization.

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:

  1. Test a product page and the home page in Google's Rich Results Test and note every item it detects.
  2. Search your theme code (Online Store › Themes › Edit code) for application/ld+json and structured_data.
  3. 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

MethodHow it worksGood forWatch out for
Theme codeA Liquid snippet with a JSON-LD block, rendered from a templateFull control, no subscriptionLost or duplicated on theme change; needs Liquid knowledge
App embedA theme app extension switched on in the theme editor under App embedsNo code edits; switch off to removeMust not overlap the theme's own markup
App (script)An app adds JSON-LD with JavaScript after the page loadsQuick set-upNot 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.

  1. In the code editor, under Snippets, add a new snippet such as schema-product.
  2. Paste in the template below and adjust it.
  3. Render it. For product pages, add {% render 'schema-product' %} to your main product section (in Dawn, sections/main-product.liquid), or to theme.liquid inside {% if request.page_type == 'product' %} … {% endif %}.
  4. 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 json filter.
  • Prices with symbols, such as "£45" instead of a number and a priceCurrency.

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.

Questions people ask

Where do I put JSON-LD in Shopify?
In a snippet rendered from the relevant template: the main product section for Product, theme.liquid (on the home page only) for Organization and WebSite. It can go in the head or the body; Google reads both.
Where do you put JSON-LD markup in a Shopify blog post?
Not in the post itself. The article template (in Dawn, sections/main-article.liquid) already outputs Article markup through the structured_data filter. To change or extend it, edit that section or a snippet rendered from it, so every post gets the same block. The rich text editor may strip script tags pasted into a post.
Can I paste JSON-LD into a Shopify page or product description?
It is not a good idea. The rich text editor may strip or alter script tags, and a fixed block goes out of date when prices or stock change. Use a theme snippet with Liquid values or an app.
Why use the json filter in Shopify JSON-LD?
It outputs the value as a properly quoted and escaped JSON string. Without it, a quote mark or line break in a product title or description breaks the whole block.
Is there a free JSON-LD generator for Shopify?
Shopify's structured_data Liquid filter outputs Product and Article markup for free, and our schema markup generator builds static JSON-LD from a form. Static output needs updating by hand when details change.
Will adding JSON-LD to Shopify improve my rankings?
Not directly. Google says structured data is not a ranking factor. It makes pages eligible for rich results such as price and stock in search, which can make a result more useful to shoppers.
How to add structured data to Shopify without an app?
Add a Liquid snippet containing a JSON-LD script tag to your theme, fill it from Shopify objects with the json filter, and render it from the right template. Duplicate the theme first, check for existing markup, and test the copy before publishing.
Do I need to know Shopify code to add schema?
Not if you use an app embed or an app, which add markup without editing theme files. Writing JSON-LD by hand needs basic Liquid and care with the json filter, so many merchants ask a developer or use an app.

See what Google sees on your store

Run an audit in minutes. Every schema block, every error and duplicate, with its source.

Install Schema Clinic