A custom website offers no platform mechanism at all, so the method depends entirely on how your site is built and hosted. A folder of static HTML files, a static site generator, and a server rendered framework each place the JSON-LD block in a different spot, and a site that renders in the browser needs a different answer from one that renders on the server. One limit shapes everything. The block must sit in the first HTML response for the page, and you write it wherever your setup produces that HTML.
What makes a custom website different
Unlike a self-hosted application with a template layer and a deploy pipeline, a custom site may hold no shared template at all. The practical question is not who owns the stack but how each product page HTML comes into existence. That answer decides the technique, and the four common cases need four different instructions. Pick the wrong case and the markup either never ships or ships only after JavaScript runs, which AI crawlers will not wait for.
Work through it in this order
Check what the server really sends. Pull a product page with curl, or use view-source, and hunt for the application/ld+json section. Ignore what the browser DOM shows you. On custom sites, especially ones built with frontend frameworks, the DOM routinely displays markup that was injected after load and never appeared in the first response.
Place the block at the point where your HTML gets made.
- Static HTML files. When each product is its own HTML file, paste the JSON-LD script block into the head of each product page, with that product actual values. When the pages share a common header include or snippet, place the block there only when the values can vary per page. A shared include carrying one product price on every page is worse than no markup.
- Static site generator, such as Hugo, Eleventy, or Jekyll. Add the block once to the product layout or partial, with template variables drawing from each page front matter, including name, price, SKU, and stock status. Each product page then receives accurate markup at build time. Rebuild and confirm the generated files hold it.
- Server rendered framework, such as Next.js or Nuxt. Add the block to the product page component head so it renders into the server response. Verify with curl that the JSON-LD sits in the raw HTML, not added during hydration.
- Client rendered single page app. When product content only exists after JavaScript runs, a JSON-LD block in the served HTML has to be produced another way: pre-render the product pages, render them on the server, or generate static product pages for crawlers. Markup injected solely by client side scripts is invisible to AI crawlers, and this case has to be fixed before any schema work counts.
Keep every value matched to the page. Whatever method you use, the block must mirror the page exactly. Price, currency, and stock status must agree. With static sites, a page update must come with a block update. With generated sites, the front matter or data source governs both sides.
Validate the served HTML. Test a product address through Google's Rich Results Test and the Schema Markup Validator. Check a variant page and a product that is out of stock, and validate again after any rebuild or framework upgrade, since those are the moments the block quietly disappears.
A maker site that fixed thirty pages with one edit
Imagine a wooden toy maker site built with a static site generator, Willow and Wren Toys, with twenty eight product pages generated from markdown files. The owner checks the built HTML and finds no structured data. The owner adds a JSON-LD block to the product layout with variables for name, price, and stock status fed by each page front matter, rebuilds, and confirms the block appears in the generated files with per product values. Twenty eight pages fixed with one layout edit. Had that same site been twenty eight hand written HTML files with no shared layout, the task would really have been twenty eight paste jobs, and the maintenance plan would matter more than the technique.
Two companions worth adding
Once the markup sits in the first HTML, two more pieces help AI tools use it. An llms.txt file gives tools a short plain summary of what your business sells and where the key pages sit. Open crawler permissions in robots.txt make sure AI crawlers can reach the pages carrying the markup at all. Aizii Learn covers both topics in full, in separate guides.
What this guide leaves out
This guide covers getting valid markup into the first HTML of a custom built site, whatever produces that HTML. It does not cover keeping the markup fresh as prices and inventory move, which on static sites is a manual discipline, getting AI crawlers to your pages, or letting an AI tool finish a checkout, which is a separate transaction job.
Frequently Asked Questions
Where does the block go on a custom site?
Wherever your setup produces the first HTML: the head of each static file, the product layout of a static site generator, or the product page component head of a server rendered framework.
My site renders in the browser. Can I still add schema?
Only when the block reaches the first HTML another way: pre-render the product pages, render them on the server, or generate static product pages for crawlers. Markup injected solely by client side scripts is invisible to AI crawlers.
Can I place one shared block in a common header include?
Only when the values can vary per page. A shared include carrying one product price on every page is worse than no markup.
When should I re-validate?
After any rebuild or framework upgrade, since those are the moments the block silently disappears. Always test a variant page and an out of stock product.
Verified Sources & Technical Documentation
- Google Search Central, Product structured data Specific https://developers.google.com/search/docs/appearance/structured-data/product
- Schema.org, Product type General Docs https://schema.org/Product
links marked specific point to the page that supports the claim in this guide. Links marked general docs point to the vendor's general docs section for that topic, not to a page that proves every step. Check the vendor docs for the current path before relying on a menu name or click path in this guide.