Excluding noindex pages from next-sitemap in a custom implementation

1 replies
Last updated: Jun 22, 2023
Hi all 👋 so we are using the next-sitemap, but I'd like to exclude all pages that are set to noindex. I have been told that "As discussed, this looks relatively tricky to achieve with the current implementation (next-sitemap) due to the fact that it executes after the main site build, and outside the scope where access to Sanity is available." but I'd like to verify this. It seems like a pretty obvious thing most people would want so I'm surprised this is considered a tricky thing to achieve. Any tips?
Jun 21, 2023, 8:19 AM
We made our own that runs in preBuildUtilities.js 🙂It’s a very simple loop through all document types we want included, and we exclude the hidden, can rank them according to their _search_priority_ attribute etc.
In the end it’s just a
fs.writeFileSync('./public/sitemap.xml', sitemap)
to write it to the filesystem.
Jun 22, 2023, 8:26 AM

Sanity– build remarkable experiences at scale

The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?

Categorized in