Free auditStart free
GuideSanity · Headless CMS guide

Sanity SEO

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 withChatGPTClaudePerplexityGoogleAI Mode
01Checklist

Model metadata once and render it in the frontend

Create a reusable SEO object in your Sanity schema with fields for the page title, description, and any other values your frontend actually renders. Sanity’s guide suggests 65 and 155 character limits for the title and meta description, plus fields for 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.
First2
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.
Next1
Keep canonical URLs derived from the public route. Editors should not enter a second URL unless that page intentionally duplicates content elsewhere.
Then1
For translated documents, render the correct language-specific route and metadata for each published translation.

Sanity’s SEO implementation guide 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.

02Checklist

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, 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. 01Filter drafts and scheduled content before mapping slugs to URLs. Skip any record whose slug is empty when you build the URL.
  2. 02Exclude records marked out of the sitemap, and apply the same rule to other document types you publish.
  3. 03Only include canonical URLs that return a successful page response. A sitemap helps discovery; it does not guarantee indexing.
  4. 04When the 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 and canonical URLs with a 200 HTTP response." For a complete workflow, see XML sitemaps and Google’s sitemap documentation.

03Explained

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.

04How 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.

01Does 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.

02How 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.

03Should 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.

04Where 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. 01The Ultimate Guide to SEO with Sanity | Sanitysanity.io · checked 2026-10-24
  2. 02Learn about sitemaps | Google Search Centraldevelopers.google.com · checked 2026-10-24
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