# Sanity SEO

> Build Sanity SEO around reusable metadata fields, frontend rendering, canonical URL rules, and a sitemap that includes only live pages.

Canonical: https://scaplet.com/seo/sanity

Guide Sanity Sanity · Headless CMS guide

Build Sanity SEO around reusable metadata fields, frontend rendering, canonical URL rules, and a sitemap that includes only live pages.

4 min

read

2

sources

Oct 24, 2026

updated

Scaplet Editorial Team

author

In one line

Sanity stores content; your frontend decides which URLs exist and what HTML search engines receive. Add reusable SEO fields to the content types that need them, render those values into each page’s head, and generate the sitemap from published records that have a real canonical URL. Verify the deployed response because a complete Studio schema alone does not create page metadata or a sitemap.

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 with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fsanity%20(%22Sanity%20SEO%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fsanity%20(%22Sanity%20SEO%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fsanity%20(%22Sanity%20SEO%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fsanity%20(%22Sanity%20SEO%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

On this page

## 4 parts, 4 minutes.

1. [Model metadata once and render it in the frontend 01](#model-metadata-once-and-render-it-in-the-frontend)
2. [Generate sitemap URLs from published, indexable records 02](#generate-sitemap-urls-from-published-indexable-records)
3. [Treat asset text and internal references as content data 03](#treat-asset-text-and-internal-references-as-content-data)
4. [Check the production route from content record to HTML 04](#check-the-production-route-from-content-record-to-html)

_01_Checklist

## Model metadata once and render it in the frontend

Create a reusable SEO object in your Sanity schema with fields for the [page title](/glossary/title-tag), description, and any other values your frontend actually renders. Sanity’s guide suggests 65 and 155 character limits for the title and [meta description](/glossary/meta-description), plus fields for [noindex](/glossary/noindex)/nofollow, canonical status, and sitemap inclusion. Add field descriptions and validation so editors know what each field controls. Keep defaults at the content-type or shared-template level, then allow page-specific values when a page has a different audience or [search intent](/glossary/search-intent).

First_2_
Map each field to visible content and the matching HTML head tag. A field saved in Studio has no search effect until the frontend uses it.

Provide a fallback for blank values, such as the document title and summary, instead of emitting an empty tag.

Next_1_
Keep canonical URLs derived from the public route. Editors should not enter a second URL unless that page intentionally duplicates content elsewhere.

Then_1_
For translated documents, render the correct language-specific route and metadata for each published translation.

Sanity’s [SEO implementation guide](https://www.sanity.io/seo-with-sanity) recommends a reusable SEO object and explains that the frontend framework must output the page tags. Treat Sanity Studio as the content source; inspect the rendered page as the deliverable.

_02_Checklist

## Generate sitemap URLs from published, indexable records

Sanity does not choose your website’s final routes or provide a universal sitemap for every frontend. Query the documents that are published, have a usable [slug](/glossary/url-slug), and are meant to be indexed. Build absolute URLs using the same route logic as the frontend, then emit the XML from your framework or deployment layer.

1. 01 Filter drafts and scheduled content before mapping slugs to URLs. Skip any record whose `slug` is empty when you build the URL.
2. 02 Exclude records marked out of the sitemap, and apply the same rule to other document types you publish.
3. 03 Only include canonical URLs that return a successful page response. A sitemap helps discovery; it does not guarantee indexing.
4. 04 When the [URL structure](/glossary/url-structure) changes, update the route builder and redirects together, then compare sitemap entries with the deployed routes.

GROQ query for published posts (from Sanity's SEO guide)

```
*[_type == 'post' && !(_id in path("drafts.**")) && includeInSitemap != false && publishedAt < now()] | order(publishedAt desc) { slug }
```

Sanity’s example query filters draft IDs, future publish dates, and an `includeInSitemap` flag. Its guide says: "You will want to include only [indexable](/glossary/indexability) and canonical URLs with a 200 HTTP response." For a complete workflow, see [XML sitemaps](/glossary/xml-sitemap) and [Google’s sitemap documentation](https://developers.google.com/search/docs/crawling-indexing/sitemaps/overview).

_03_Explained

## Treat asset text and internal references as content data

Image descriptions belong in the content model too. Sanity’s guide recommends setting alt text at image level with the ability to overwrite it at document level; the document-level value is useful when the same asset has a different meaning in a different context. Describe what a reader needs to understand from the image, and leave decorative images with empty alt text in the frontend.

Use document references for internal links where your content model supports them. Sanity says that with references, when you change a URL, all of your internal links change too, which reduces stale internal paths. The frontend still needs to render these references as links and handle deleted or unpublished targets.

Sanity’s guide says its asset CDN can resize images, adjust quality, and convert to WebP when you append `?auto=format` to the image URL. Request an appropriate size per layout rather than sending a large original to every viewport.

_04_How it works

## Check the production route from content record to HTML

1. 1

### Choose one page for each content type

Use a published article, a translation, and a record that should stay out of search. Confirm each record has the expected slug, metadata, language, and publication state.
2. 2

### Inspect the first HTML response

Request the production URL and check its title, description, canonical, language, main heading, and primary text. Confirm the values are present in the server response where your rendering mode supports it.
3. 3

### Compare routes with the sitemap

Check that the public page returns the expected status and canonical, appears once in the sitemap, and that drafts or excluded records are absent.
4. 4

### Test a changed slug end to end

Update a test document’s slug, deploy the route and redirect behavior, then verify the old URL and new canonical URL. Check internal references for links to the former path.

Questions

## Asked a lot.

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

_01_ Does Sanity automatically create SEO tags for my website?

Sanity stores the fields you model, but your frontend must query them and render the title, description, canonical, and other tags into the page. Verify the deployed HTML rather than relying on the Studio record alone.

_02_ How do I keep Sanity drafts out of my sitemap?

Filter draft IDs in the GROQ query, include only records whose publish time has passed, and require a usable slug. Apply those rules to each document type included in your sitemap.

_03_ Should my Sanity sitemap include preview URLs?

No. Build sitemap links from the public production origin and the same route rules used by your site. Preview and authenticated draft URLs are not public canonical pages.

_04_ Where should image alt text live in Sanity?

Store shared descriptive text with the asset when it has the same meaning wherever it appears. Store it on the page’s image reference when the context changes how the image should be described.

Sources · 2

## Every fact, linked and dated.

Official docs first. The date is when we last opened each page.

- sanity.io
- google.com

1. 01 [The Ultimate Guide to SEO with Sanity | Sanity](https://www.sanity.io/seo-with-sanity) sanity.io · checked 2026-10-24
2. 02 [Learn about sitemaps | Google Search Central](https://developers.google.com/search/docs/crawling-indexing/sitemaps/overview) developers.google.com · checked 2026-10-24

## Keep learning

[All platform guides](/seo)

[Learn Sanity XML sitemap Headless CMS](/seo/sanity/xml-sitemap) [Related XML sitemap Crawling and indexing](/glossary/xml-sitemap) [Read next Sanity structured data CMS](/seo/sanity/structured-data) [Do Run a free site audit Free, about two minutes](/site-audit)

Nearby in platform guides
[React lazy loading and SEO](/seo/react/lazy-loading) [React Router (Remix) redirects](/seo/remix/redirects) [Sanity image SEO](/seo/sanity/image-seo) [Sanity redirects](/seo/sanity/redirects)

More in Headless CMS
[Contentful SEO](/seo/contentful) [Sanity SEO](/seo/sanity)

Terms on this page
[Title tag](/glossary/title-tag) [Meta description](/glossary/meta-description) [Noindex](/glossary/noindex) [Search intent](/glossary/search-intent) [URL slug](/glossary/url-slug) [URL structure](/glossary/url-structure) [XML sitemap](/glossary/xml-sitemap) [Indexability](/glossary/indexability)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

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

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
