In short
Structured data (most often a JSON-LD block, for JavaScript Object Notation for Linked Data) describes the page to search engines: product, article, organization, breadcrumb. When it is generated or modified by JavaScript, it can be missing from the HTML crawlers receive, appear twice or contradict the visible content. This check consists of comparing the initial HTML with the final render, then having the server produce each block, once, with the same values as the page.
Why it matters
Google reads structured data after rendering: its documentation accepts JSON-LD injected by JavaScript or by Google Tag Manager. It sets two limits, however. First, you need to test the result, because a script that crashes injects nothing. Second, for Product markup, Google warns that dynamically generated markup can make Shopping crawls less frequent and less reliable.
Other readers are less forgiving. Generative engine crawlers mostly fetch the raw HTML: an analysis published by Vercel in December 2024 found that the OpenAI, Anthropic and Perplexity crawlers did not execute JavaScript. JSON-LD added on the client side does not exist for them. No generative engine documents how it uses schema.org, either: the GEO (Generative Engine Optimization) benefit of clean markup remains indirect.
Finally, JavaScript creates failures of its own: two Product blocks with different prices (one from the theme, one from an app), a stale block the client does not update after an in-app navigation, or a block emptied by a hydration error.
What it improves
- Eligibility for rich results Price, reviews, breadcrumb, articles. Google never guarantees they will be shown.
- Shopping reliability A
Productpresent in the initial HTML avoids the limit documented for dynamic markup. - Reading by other crawlers Bing, social networks and AI crawlers read what the server sends.
- Consistency A single block per entity, aligned with the visible content, avoids contradictory signals.
- Rankings No direct effect; structured data helps search engines understand the page and obtain rich displays.
How to check
First count the JSON-LD blocks present in the initial HTML:
curl -s https://example.com/produits/theiere-fonte/ | grep -o -i 'application/ld+json' | wc -l
Then, on the same page opened in Chrome, paste this code into the developer tools console to list the blocks in the rendered DOM:
console.table([...document.querySelectorAll('script[type="application/ld+json"]')].map((script, index) => {
try {
const data = JSON.parse(script.textContent);
const items = [].concat(data['@graph'] ?? data);
return { index, types: items.map((item) => item['@type']).join(', ') };
} catch (error) {
return { index, error: error.message };
}
}));
Read the result as follows:
| Initial HTML | Rendered DOM | Diagnosis |
|---|---|---|
| 2 blocks | 2 blocks, same types | Compliant |
| 0 blocks | 1 block or more | Generated by JavaScript: Google can read it, other crawlers cannot |
1 Product block |
2 Product blocks |
Duplicate added by a script or an app |
| 1 block | 0 blocks or parsing error | Block removed or broken on the client side |
Confirm with Google:
- Rich Results Test: enter the URL, not the code. Google recommends URL input, because code input has limitations with JavaScript. “View tested page” shows the rendered HTML.
- Search Console: URL Inspection, then “Test live URL”, lists the items detected. The reports in the “Enhancements” section track errors across the site.
- Schema Markup Validator: useful for validating the schema.org vocabulary beyond Google's types. How it handles JavaScript is not documented: paste in the raw HTML obtained with curl to test what crawlers read without rendering.
Finally, compare the key values (price, availability, rating, date) with the displayed text.
How to implement
Before you start
| Source of the JSON-LD | Read by Google | Read by crawlers without rendering | Verdict |
|---|---|---|---|
| Generated by the server or at build time | Yes | Yes | Recommended |
| Injected by JavaScript on load | Yes, after rendering | No | Acceptable except for Product, to be tested |
| Injected by Google Tag Manager | Yes, after rendering | No | Last resort |
Three rules for every environment:
- A single source per entity: the theme, the SEO plugin and apps must not each publish their own
ProductorOrganization. - The same data as the page: produce the JSON-LD from the variables that display the price or the title, not from a second request. Google requires markup to faithfully represent the visible content; see align markup with visible content (opens in a new tab).
- Escaped JSON: replace
<with<when serializing, so that a value containing</script>does not close the tag.
WordPress
Versions WordPress 6.4 and later (verified up to 7.1), WooCommerce 9 and 10, Yoast SEO and Rank Math in their November 2026 versions.
Yoast SEO and Rank Math produce their JSON-LD graph on the server side, in the <head>: it is present in the initial HTML. Duplicates come from elsewhere:
- WooCommerce generates its own
Productblock. If an SEO or schema plugin adds a second one, disable one of the two in the plugin's settings. Thewoocommerce_structured_data_productfilter lets you modify WooCommerce's block. - Themes: some insert their own
ArticleorOrganizationmarkup. Search forld+jsonin the child theme's code and remove the redundant source. - JavaScript review or FAQ plugins: check with curl that their markup is in the initial HTML; otherwise look for a server-side rendering option.
Clear the page cache after each change, then run the curl test again.
Shopify
Versions Shopify, all plans, Online Store 2.0 themes, November 2026.
The theme produces the JSON-LD in Liquid, so on the server side. Recent themes use the structured_data filter, which returns a Product, or a ProductGroup if the product has variants, and an Article for blog posts. In Online Store > Themes > … > Edit code, the product section contains:
<script type="application/ld+json">
{{ product | structured_data }}
</script>
Review or FAQ apps often add their markup through JavaScript, sometimes as a second Product. Prefer the app option that writes ratings into metafields or into a Liquid block, then check that only one Product block remains in the initial HTML.
Next.js
Versions Next.js 15 and 16 (App Router).
Next.js recommends rendering JSON-LD in a native <script> tag from layout.js or page.js. In a server component, it is then present in the initial HTML:
// app/produits/[slug]/page.tsx
export default async function Page({ params }: { params: Promise<{ slug: string }> }) {
const { slug } = await params;
const product = await getProduct(slug);
const jsonLd = {
'@context': 'https://schema.org',
'@type': 'Product',
name: product.name,
image: product.image,
description: product.description,
offers: {
'@type': 'Offer',
price: product.price,
priceCurrency: 'EUR',
availability: 'https://schema.org/InStock',
},
};
return (
<section>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd).replace(/</g, '\\u003c') }}
/>
<h1>{product.name}</h1>
</section>
);
}
getProduct is your data access function. Do not use next/script for JSON-LD, and do not generate it in a useEffect: it would only exist after execution on the client.
Nuxt
Versions Nuxt 3.x and 4.
useHead in the page's <script setup> writes the block during server rendering:
const { data: product } = await useFetch(`/api/products/${useRoute().params.slug}`);
useHead({
script: [
{
type: 'application/ld+json',
innerHTML: JSON.stringify({
'@context': 'https://schema.org',
'@type': 'Product',
name: product.value.name,
offers: { '@type': 'Offer', price: product.value.price, priceCurrency: 'EUR' },
}).replace(/</g, '\\u003c'),
},
],
});
The Nuxt SEO module also offers composables dedicated to schema.org. In both cases, check that the route is not set to ssr: false (in nuxt.config or in routeRules): with client-only rendering, the block only exists after JavaScript has run.
Astro
Versions Astro 5 to 7.
Astro pages are rendered on the server or at build time. Astro does not process a <script> tag that carries any attribute other than src: with type="application/ld+json", it is left as is:
---
const schema = {
'@context': 'https://schema.org',
'@type': 'Article',
headline: Astro.props.title,
datePublished: Astro.props.date,
};
---
<script type="application/ld+json" set:html={JSON.stringify(schema).replace(/</g, '\\u003c')} />
Laravel
Versions Laravel 11 to 13; Inertia 2 and 3.
Build the array in the controller or a view component, then serialize it in the Blade template:
<script type="application/ld+json">
{!! json_encode($schema, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_HEX_TAG) !!}
</script>
JSON_HEX_TAG encodes < and >. With Inertia and a React or Vue front end, the JSON-LD is only in the initial HTML if Inertia's server-side rendering is enabled; otherwise, place it in the root Blade view.
Symfony
Versions Symfony 6.4, 7.4 and 8.x, Twig 3.
In the Twig template:
<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>
Google Tag Manager
Google documents this method: a new “Custom HTML” tag, the JSON-LD block as its content, variables to reuse the page's values rather than duplicate them, then publishing the container. It has three drawbacks: the markup only exists after the container has run, it depends on consent if the container is blocked until the visitor accepts, and it escapes most crawlers that do not render. Keep it for sites whose templates you cannot modify, and never for Product.
Single-page applications
Without server rendering (React, Vue or Angular in client mode), all JSON-LD is injected by JavaScript. Update it on every route change by replacing the existing block rather than adding a new one, otherwise the page accumulates the blocks of previous pages. The lasting solution is prerendering or server rendering for pages that carry structured data: see prefer SSR/SSG for critical content (opens in a new tab).
Common mistakes
- Testing with the “code” input of the Rich Results Test: you are testing your copy, not what Google gets from the URL.
- Two
Productblocks with different values: one from the theme, one from an app. Google may pick the wrong price. - Blocks piling up in a single-page application: each in-app navigation adds a block without removing the previous one.
- JSON-LD generated in a
useEffectoronMounted: invisible in the initial HTML even though the framework supports server rendering. - Price or stock updated by JavaScript in the page but not in the JSON-LD: the markup contradicts the visible content.
- Markup injected after consent: the Tag Manager container does not run for a crawler that does not click.
- Validating a single page: test one URL per template (product with and without variants, article, category).
Frequently asked questions
Does Google read JSON-LD added by JavaScript?
Yes, Google reads JSON-LD injected by JavaScript or by Google Tag Manager, because it processes structured data after rendering the page. Its documentation nevertheless asks you to test the result with the Rich Results Test in URL mode, and warns that dynamically generated Product markup can make Shopping crawls less frequent and less reliable. Crawlers that do not execute JavaScript do not see this markup.
Do AI crawlers read structured data?
AI crawlers read what the server sends them, and according to an analysis Vercel published at the end of 2024, those from OpenAI, Anthropic and Perplexity do not execute JavaScript. JSON-LD present in the initial HTML is therefore accessible to them; JSON-LD injected on the client side is not. None of these companies documents how it uses schema.org: clean markup guarantees neither citation nor recommendation.
Is having several JSON-LD blocks on one page a problem?
Several JSON-LD blocks on a page are not a problem when they describe different entities, for example a breadcrumb, an organization and a product. The problem comes from duplicates: two Product blocks for the same item, often one produced by the theme and the other by an app, with prices or ratings that differ. Keep a single source per entity, or group everything in a single graph.
Does the Schema Markup Validator execute JavaScript?
How the Schema Markup Validator handles JavaScript is not documented by schema.org. To find out what Google sees after rendering, use the Rich Results Test with the page URL or the URL Inspection tool in Search Console. To find out what crawlers read without rendering, fetch the raw HTML with curl and paste it into the validator: you are then testing exactly the initial HTML.
Resources
- Google Search Central: Generate structured data with JavaScriptdevelopers.google.com
- Google Search Central: General structured data guidelinesdevelopers.google.com
- Google Search Central: Understand the JavaScript SEO basicsdevelopers.google.com
- Next.js: JSON-LDnextjs.org
- Shopify: structured_data Liquid filtershopify.dev
- Vercel: The rise of the AI crawlervercel.com
Updated on
Topic checklist (PDF)