# Prefer JSON-LD

- Check 15.13 · Schema.org structured data · Important
- Source: https://checklist-seo-geo.com/en/schemaorg-structured-data/prefer-json-ld
- Move your structured data to JSON-LD, without duplicating the theme's microdata, on WordPress, Shopify, PrestaShop, Drupal, Laravel or Next.js.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/schemaorg-structured-data/prefer-json-ld.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

Structured data comes in three formats: JSON-LD (JavaScript Object Notation for Linked Data), a separate block inside a `<script>` tag; Microdata and RDFa, attributes slipped into the HTML tags. Google accepts all three but recommends JSON-LD, which is easier to produce and maintain. Once the check is done, each entity is described only once, in a JSON-LD block generated on the server, and the old `itemprop` or `property` attributes that duplicated it are gone.

## Why it matters

Google says it plainly: the three formats are equivalent for it as long as the markup is valid, but it recommends JSON-LD because it is the easiest solution to implement and maintain at scale. The markup is not interleaved with the visible text, which makes it easy to express nested objects (the address of an event's venue) and to connect entities through their `@id`.

The practical problems of microdata come from being embedded in the template:

- **Fragility**: an HTML redesign, a component change or a developer moving a `<div>` breaks the markup without anyone noticing.
- **Duplicates**: the theme marks up the product in microdata, the SEO plugin marks it up in JSON-LD. Google sees two products, sometimes with two prices.
- **Limits**: relationships between entities in different areas of the page (author in the header, article in the body, organization in the footer) are hard to express.

JSON-LD also helps with bots that do not run JavaScript, provided it is produced by the server: a block readable as is in the initial HTML. No generative engine documents how it uses schema.org, however; the GEO (Generative Engine Optimization) benefit remains indirect.

## What it improves

- **Maintenance**: one place to change per template, testable independently of the HTML.
- **Reliability**: less breakage during template redesigns and theme changes.
- **Consistency**: no more duplicates across formats, a single value per property.
- **Entity graph**: `@id` values and cross-references are natural to write.
- **Rankings and rich results**: no gain for the same markup. Valid, complete Microdata is treated like its JSON-LD equivalent.

## How to check

Count the three formats in the initial HTML of one page per template:

```bash
URL=https://example.com/produits/theiere-fonte/
curl -s "$URL" -o /tmp/page.html
echo "JSON-LD: $(grep -c -i 'application/ld+json' /tmp/page.html)"
echo "Microdata: $(grep -o -i 'itemscope' /tmp/page.html | wc -l)"
echo "RDFa: $(grep -o -i -E ' (vocab|typeof)=' /tmp/page.html | wc -l)"
```

Then paste the URL into the Schema Markup Validator: it lists each detected entity with its format. Two `Product` entities (one in Microdata, one in JSON-LD) point to a duplicate.

Expected result: one or more JSON-LD blocks, zero `itemscope` for entities already described in JSON-LD, a single entity per real object on the page.

> **Good to know:** microdata for an entity that the JSON-LD does not describe is still acceptable. The problem is not mixing formats, but describing the same entity twice.

## How to implement

### Before you start

A migration method shared by every environment:

1. **Inventory**: for each template (home, article, product, category, contact), list the entities and their current format with the Schema Markup Validator.
2. **Single source**: decide what produces the JSON-LD (SEO plugin, theme, custom code) for each entity.
3. **Write the JSON-LD** from the same variables as the display, in the `<head>` or at the end of the `<body>`: both locations are read.
4. **Remove the attributes** `itemscope`, `itemtype`, `itemprop`, `vocab`, `typeof` and `property` (except Open Graph `<meta property="og:…">` tags, which are unrelated) for the migrated entities.
5. **Check**: test before and after on one URL per template, comparing the detected properties.

Serialization rule: escape `<` as `<` so that text containing `</script>` does not close the tag.

### WordPress

Versions: WordPress 6.4 to 7.1, WooCommerce 9 and later; Yoast SEO, Rank Math and SEOPress in their November 2026 versions.

Yoast SEO, Rank Math and SEOPress output JSON-LD in the `<head>`, and WooCommerce outputs its `Product` block in JSON-LD. Microdata almost always comes from the theme: `itemprop="headline"`, `itemtype="https://schema.org/WPHeader"` or `CreativeWork` attributes on posts.

- Search for `itemscope` in the theme files (`grep -rn "itemscope" wp-content/themes/votre-theme/`).
- If the theme offers an option to disable its schema markup, use it; otherwise, override the relevant templates in a child theme and remove the attributes.
- Keep a single structured data plugin: two active SEO plugins produce two graphs.

Clear the page cache, then run the count again.

### Shopify

Versions: Online Store 2.0 themes (Horizon, Dawn) and older themes, all Shopify plans, November 2026.

Shopify's recent themes (Horizon, the default theme for new stores, and Dawn) write the JSON-LD with the `structured_data` Liquid filter, in the product section and the article section:

```liquid
<script type="application/ld+json">
  {{ product | structured_data }}
</script>
```

Some older themes still mark up the product page in microdata (`itemscope itemtype="http://schema.org/Product"` in `sections/product-template.liquid` or equivalent). In `Online Store > Themes > … > Edit code`, remove these attributes from the template and add the block above to the same section. Duplicate the theme before making any change.

### PrestaShop

Versions: PrestaShop 8 and 9, Classic and Hummingbird themes.

The Classic theme and Hummingbird, the default theme for new installations since PrestaShop 9.1, output JSON-LD in `templates/_partials/microdata/` (`head-jsonld.tpl`, `product-jsonld.tpl`, `product-list-jsonld.tpl`). Older themes, or themes bought on a marketplace, often use microdata in `product.tpl`. In a child theme, copy the JSON-LD files from the Classic theme matching your version, include them in the `<head>`, then remove the `itemprop` attributes from the templates. Clear the cache in `Advanced Parameters > Performance`.

### Magento

Versions: Magento Open Source and Adobe Commerce 2.4.6 to 2.4.9, Luma theme.

The Luma theme marks up the product page in microdata across several templates of the catalog module. The migration goes through a child theme: override the relevant templates to remove the attributes, and output the JSON-LD in a block added to the `catalog_product_view.xml` layout, or through a structured data extension. Run `bin/magento cache:flush` after deployment.

### Drupal

Versions: Drupal 10 and 11, Metatag 2 and Schema.org Metatag 3 modules.

The Schema.org Metatag module, which builds on Metatag, writes the JSON-LD in the `<head>`. Configure it in `Configuration > Search and metadata > Metatag`, per content type, with tokens. If a module (for example RDF, removed from core in Drupal 11 and now a contributed module) or a theme also adds RDFa attributes (`property`, `typeof`) to fields, disable that markup for the entities described by Schema.org Metatag.

### Joomla

Versions: Joomla 5 and 6.

Joomla 5 and 6 include Schema.org plugins that output JSON-LD, configured per article in the Schema tab. Layouts inherited from earlier versions, or third-party templates, may contain microdata: check the template overrides (`html/com_content/`) and remove the attributes that duplicate the JSON-LD.

### Wix

Versions: Wix Editor and Wix Studio, all plans, November 2026.

Wix automatically adds JSON-LD structured data to several page types (products, blog posts, events). To add your own, open the page's SEO settings, Advanced SEO tab, and paste a JSON-LD block into the structured data markup field. SEO settings by page type let you edit the default markup of a whole set of pages.

### Squarespace

Versions: Squarespace 7.1, Core, Plus and Advanced plans, November 2026.

Squarespace produces its own markup for pages, products and posts. For an additional block, use page-level code injection (page settings, Advanced section) or site-wide code injection (the Code Injection panel, found under Custom code in the Pages panel of the current interface, no longer in `Settings > Advanced`), available on the Core, Plus and Advanced plans. Do not redeclare an entity that the platform already describes.

### Webflow

Versions: Webflow, paid site plans, November 2026.

Add the JSON-LD in the page settings, Custom code section, in the `<head>` code field. On a CMS collection template, insert the dynamic fields (name, image, date) into the block rather than fixed values, and check that no custom `itemprop` attribute remains on the template's elements.

### Laravel

Versions: Laravel 11 to 13, spatie/schema-org 3 to 5 optional (version 5 requires PHP 8.4).

Build the PHP array in the controller, a view component or a dedicated class, then serialize it in the layout:

```php
<script type="application/ld+json">
    {!! json_encode($schema, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_HEX_TAG) !!}
</script>
```

`JSON_HEX_TAG` encodes `<` and `>`. The `spatie/schema-org` package provides typed classes for every schema.org type and a `Graph` object that groups several entities in a single block.

### Symfony

Versions: Symfony 6.4, 7.4 and 8, Twig 3.

In Twig:

```twig
<script type="application/ld+json">
    {{ schema|json_encode(constant('JSON_UNESCAPED_SLASHES') b-or constant('JSON_UNESCAPED_UNICODE') b-or constant('JSON_HEX_TAG'))|raw }}
</script>
```

### Next.js

Versions: Next.js 15 and 16 (App Router and Pages Router).

The Next.js documentation recommends a native `<script>` tag rendered in `layout.js` or `page.js`:

```tsx
export default function Page() {
  const jsonLd = {
    '@context': 'https://schema.org',
    '@type': 'Article',
    headline: 'Descaling a cast iron kettle',
    datePublished: '2026-10-14',
  };

  return (
    <article>
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd).replace(/</g, '\\u003c') }}
      />
      <h1>Descaling a cast iron kettle</h1>
    </article>
  );
}
```

In a server component, the block is in the initial HTML. With the Pages Router, put the same tag in the page component (`pages/…`): it also ends up in the pre-rendered HTML. Do not use `next/script` for JSON-LD.

### Nuxt

Versions: Nuxt 4 (same code on Nuxt 3, end of life since July 2026), Nuxt Schema.org module 6 or 7 (version 7 requires Nuxt 4.6 or later).

`useHead` writes the block during server rendering:

```js
useHead({
  script: [
    {
      type: 'application/ld+json',
      innerHTML: JSON.stringify(schema).replace(/</g, '\\u003c'),
    },
  ],
});
```

The Nuxt Schema.org module (part of Nuxt SEO) provides dedicated functions that produce a JSON-LD graph with its `@id` values.

### Astro

Versions: Astro 5 to 7.

```txt
---
const schema = { '@context': 'https://schema.org', '@type': 'WebPage', name: Astro.props.title };
---
<script type="application/ld+json" set:html={JSON.stringify(schema).replace(/</g, '\\u003c')} />
```

### Google Tag Manager

JSON-LD injected by a Custom HTML tag is read by Google after rendering, but not by bots that do not run JavaScript, and it depends on the container loading. Keep this route for sites whose templates you cannot edit, and never use it for `Product`. See [check rendered structured data](https://checklist-seo-geo.com/en/javascript-html-rendering/check-rendered-structured-data).

## Common mistakes

- **Migrating without removing the microdata**: the page now describes the same product or article twice.
- **Writing JSON-LD by hand with fixed values**: it stops matching the content at the first edit.
- **Deleting the Open Graph tags** in the belief that you are removing RDFa: `og:title` and its siblings are used for social sharing.
- **Invalid JSON**: trailing comma, curly quotes pasted from a word processor, unescaped apostrophe. A single bad character invalidates the whole block.
- **JSON-LD block generated on the client** when the framework supports server rendering.
- **Switching format without testing before and after**: a property present in microdata (rating, availability) can go missing in the new block.

## Frequently asked questions

### Does Google prefer JSON-LD over microdata?

Google recommends JSON-LD but does not favor any format. Its documentation states that JSON-LD, Microdata and RDFa are equivalent for it as long as the markup is valid and properly implemented. It recommends JSON-LD because it is the easiest format to implement and maintain at scale. Migrating valid, complete Microdata to JSON-LD therefore brings no ranking or display gain.

### Can JSON-LD and microdata be mixed on the same page?

Yes, as long as the same entity is not described twice. A breadcrumb in microdata and an article in JSON-LD coexist without any problem. A product marked up both by the theme in microdata and by a plugin in JSON-LD, however, shows up as two products, sometimes with different prices or ratings. Choose a single source per entity and remove the other.

### Where should the JSON-LD block go: in the head or in the body?

Google reads both locations. The head is the most common choice for general entities such as the organization, the website and the page, and SEO plugins use it. The body suits a block produced by a component, for example a product section or a video player. What matters is that the block is in the HTML sent by the server and that it exists only once.

## Resources

- [Google Search Central: Introduction to structured data and supported formats](https://developers.google.com/search/docs/appearance/structured-data/intro-structured-data?hl=en)
- [Google Search Central: Generate structured data with JavaScript](https://developers.google.com/search/docs/appearance/structured-data/generate-structured-data-with-javascript?hl=en)
- [W3C: JSON-LD 1.1](https://www.w3.org/TR/json-ld11/)
- [Next.js: JSON-LD](https://nextjs.org/docs/app/guides/json-ld)
- [Shopify: structured_data Liquid filter](https://shopify.dev/docs/api/liquid/filters/structured_data)
- [Drupal: Schema.org Metatag module](https://www.drupal.org/project/schema_metatag)
- [Spatie: schema-org for PHP](https://github.com/spatie/schema-org)

Next steps: [use stable @id values](https://checklist-seo-geo.com/en/schemaorg-structured-data/use-stable-at-id-values), [connect entities](https://checklist-seo-geo.com/en/schemaorg-structured-data/connect-entities) and [fill in required and recommended properties](https://checklist-seo-geo.com/en/schemaorg-structured-data/fill-required-recommended-properties).
