Sanity SEO
Build Sanity SEO around reusable metadata fields, frontend rendering, canonical URL rules, and a sitemap that includes only live pages.
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.
Where does your site stand?
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
- Free audit in 60 seconds
- Fixes drafted for your review
- ChatGPT, Perplexity, Gemini and AI Overviews tracked
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
- Re-check after big site changes
- Keep this page for reference
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
- Follow the steps below
- Top-traffic pages first
- Check again in a month
Model metadata once and render it in the frontend
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.
Generate sitemap URLs from published, indexable records
- 01Filter drafts and scheduled content before mapping slugs to URLs. Skip any record whose
slugis empty when you build the URL. - 02Exclude records marked out of the sitemap, and apply the same rule to other document types you publish.
- 03Only include canonical URLs that return a successful page response. A sitemap helps discovery; it does not guarantee indexing.
- 04When the URL structure changes, update the route builder and redirects together, then compare sitemap entries with the deployed routes.
*[_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.
Treat asset text and internal references as content data
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.
Check the production route from content record to HTML
- 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
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
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
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.
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.
Every fact, linked and dated.
sanity.io
google.com
- 01The Ultimate Guide to SEO with Sanity | Sanitysanity.io · checked 2026-10-24
- 02Learn about sitemaps | Google Search Centraldevelopers.google.com · checked 2026-10-24
Tools point. Agencies advise. This one ships.
Run the free audit, then approve the fixes. Every change can be undone.
- 46 fixes shipped without a ticket Brightpipe
- 0→7 ChatGPT citations in six weeks Paylane