Free auditStart free
GuideSanity · Structured data

Sanity structured data

Model the source facts in Sanity, project them into page-specific JSON-LD, and validate the rendered output against Google's rules.

4 min
read
4
sources
Oct 24, 2026
updated
Scaplet Editorial Team
author
In one line

Sanity schemas define and validate editorial fields; they do not automatically generate schema.org JSON-LD. Query the fields that describe a page, map them to a Google-supported JSON-LD type in your frontend, and render that markup with the visible page content. Validate the deployed URL and keep both outputs tied to the same source record.

30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
01One fact can have two different jobs

Keep the content model and search markup separate

A Sanity schema is the editorial content model: it defines document types, fields, references, and validation for Studio. JSON-LD is a representation delivered in the website's HTML for crawlers. Sanity's glossary says: "Sanity does not ship a schema.org or JSON-LD generator as a product feature." What it provides is typed source fields and a query language that can project them into the shape your frontend serializes into the page, so your frontend owns the mapping and serialization.
Sanity field

title

Page use
Visible article or product heading
Possible JSON-LD property
headline or name, depending on the actual type
Sanity field

publishedAt

Page use
Visible publication date
Possible JSON-LD property
datePublished when the page qualifies as an Article
Sanity field

mainImage

Page use
Image shown on the page
Possible JSON-LD property
image when the target type supports it
Sanity field

author reference

Page use
Visible byline and linked author profile
Possible JSON-LD property
author as a Person or Organization entity
Sanity field

offers or product fields

Page use
Displayed price and availability
Possible JSON-LD property
Product and Offer properties only when the page and policy requirements fit
02How it works

Build a page-specific projection

  1. 1

    Pick a supported use case

    Start with a page that fits a Google search feature, such as an article or product detail. Read that feature's required properties and eligibility rules before changing the content model.

  2. 2

    Model facts editors can maintain

    Use Sanity fields and references for the real page facts: title, author, image, dates, product identifiers, price, and availability as applicable. Add validation for required values and constrain references so editors can select legitimate records.

  3. 3

    Project only what this route needs

    Use a GROQ projection in the page data query to select and rename the document fields that feed the target JSON-LD object. Keep projection logic near the frontend's rendering boundary or in a shared, typed mapper.

  4. 4

    Render JSON-LD with the same record

    Serialize a page-specific object into an application/ld+json script. Reuse the fetched record used for the visible page so title, dates, price, and availability do not drift between markup and content.

  5. 5

    Validate the production response

    Inspect the deployed HTML, run Google's Rich Results Test for eligible types, then use URL Inspection and Search Console reports after rollout. Test a missing optional field and a changed record as well as the happy path.

For a Product page, a mapper could turn the actual Sanity product title, canonical product URL, image asset URL, and current offer record into Product and Offer properties. Do not invent aggregate ratings, shipping promises, brand details, or availability to satisfy a schema checklist. If the visible page does not show a fact or the source record cannot substantiate it, leave it out.

03Checklist

Prevent drift as models and pages evolve

First2
Keep field names and JSON-LD properties distinct in code. A Sanity field named author may be a reference that must be resolved into a Person or Organization object.
Handle references that are missing or unpublished. Omit optional properties rather than emitting null, empty strings, broken URLs, or stale references.
Next2
For localized documents, map each language URL to its own visible title and canonical URL. Keep hreflang relationships consistent across the published variants.
Use the right image URL and dimensions for the page type. Sanity image assets can be transformed; test that the final URL is public and returns an image, not a Studio-only reference.
Then1
Changing a Sanity schema does not by itself change your frontend markup. Test a built or deployed route after changes to a model or mapper.

Structured data can make a page eligible for some enhanced results, but Google says it "does not guarantee that your structured data will show up in search results, even if your page is marked up correctly according to the Rich Results Test." Google also tells you not to mark up content that is not visible to readers of the page. Measure technical validity and search outcomes separately.

For Google eligibility and validation, see structured data basics and missing structured data.

Sources · 4

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • sanity.io
  • google.com
  1. 01Introduction to schemas | Sanity Docssanity.io · checked 2026-10-24
  2. 02Structured data | Sanity Glossarysanity.io · checked 2026-10-24
  3. 03General structured data guidelines | Google Search Centraldevelopers.google.com · checked 2026-10-24
  4. 04Intro to structured data markup in Google Searchdevelopers.google.com · checked 2026-10-24
Questions

Asked a lot.

3 questions people ask next, answered from the sources on this page.

01Does Sanity generate JSON-LD automatically?

No. Sanity supplies a content model and queryable documents; your frontend maps those fields to schema.org JSON-LD and renders the script in the page.

02Should Sanity schema types match schema.org types?

Not necessarily. Sanity models editorial workflows and reusable content. Map its fields and references to the schema.org type that accurately describes each public page.

03Can valid JSON-LD guarantee a Google rich result?

No. Valid markup can make an eligible page technically qualified, but Google decides whether to show an enhancement.

Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane