changeFrequency: "weekly", priority: 1 on every URL
- Problem
- Google says it ignores
<priority>and<changefreq> - Do this instead
- Drop both fields
Query page documents with GROQ, build absolute URLs and real lastmod dates in your frontend, and fix the defaults in Sanity's own sitemap lesson.
Sanity does not output a sitemap; your frontend builds one from documents. Write a GROQ query that returns each public document's path and _updatedAt, map it to absolute canonical URLs in a sitemap route, and return the XML. Sanity's own lesson works as a base but sets priority and changeFrequency, which Google ignores, and builds the origin from a deployment URL.
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.
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.
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.
page and post document with a GROQ query and returns the shape that the Next.js App Router sitemap route expects. The query is a good model for any frontend.changeFrequency: "weekly", priority: 1 on every URL<priority> and <changefreq>process.env.VERCEL_URL as the base URLVERCEL_URL as the domain of the generated deployment URL, such as *.vercel.app, and without the protocolhttps://www.example.com_updatedAt as lastModifiedreturn [] in the catch blockconsole.error and then publishes an empty sitemap*[_type in ["page", "post"] && defined(slug.current)] {
"href": select(
_type == "page" => "/" + slug.current,
_type == "post" => "/posts/" + slug.current,
slug.current
),
_updatedAt
}The lesson also keeps one query for two document types. Add a type only when it has a public route, and make sure the path logic matches your router.
published perspective excludes all unpublished changes from results, while raw returns drafts, versions and published content side by side for authenticated requests. Set perspective: 'published' on the client that powers the sitemap so a draft-only page cannot slip in. If an editor can mark a page noindex, filter it in the query (for example && noindex != true) so the sitemap never lists a URL that tells Google to skip it.
If a document redirects elsewhere, its old path should not appear. Pair the sitemap query with your Sanity redirects list.
Google caps one sitemap at 50MB (uncompressed) or 50,000 URLs; Sanity's lesson repeats the 50,000 URL cap. Beyond that, create several sitemaps and a sitemap index.
import { createClient } from '@sanity/client'
export const sitemapClient = createClient({
projectId: '<your-project-id>',
dataset: '<your-dataset>',
apiVersion: '2023-05-03',
useCdn: false,
perspective: 'published',
})Visit /sitemap.xml on the deployed site. Every <loc> should start with your production origin, not localhost or a .vercel.app host.
Run count(*[...]) as a GROQ query with the same filter as the sitemap query and compare the result with the number of <url> entries.
Publish a page in Studio and confirm its URL appears after your site's next rebuild or revalidation. Unpublish another and confirm it disappears.
Add the sitemap URL under Sitemaps in Search Console and read the status. Sanity's glossary also advises referencing the file in robots.txt.
2 questions people ask next, answered from the sources on this page.
No. Sanity stores documents and answers GROQ queries. Your frontend turns that query result into a sitemap route or generated file.
No. Google says it ignores both values, so they add nothing for Google and only create things to maintain.
Run the free audit, then approve the fixes. Every change can be undone.