I want to generate a sitemap with dato in using nextjs. I saw @m.finamor suggesting next sitemap, a package I love. We used to have a custom field for blocking the search index of a page, a simple boolean which did the job. We used this boolean to get all pages where this boolean was true only returning a couple of pages in the response (see query below).
Hmm… this feels like an oversight on our part We do have a filter for seoTags, but the only operator is a boolean exists… either it has SEO tags (of any sort) or not, which isn’t useful for differentiating between the noIndex entries and the rest.
Let me check with the devs on this!
In the meantime, do you have a lot of overall pages? Is it doable to just fetch all of them and filter on the clientside, e.g. noIndexPosts = allPosts.filter(post => post.seoTags?.noIndex === true)? Presumably you have to retrieve all the posts to build your sitemap anyway, so in that same file you can also loop through that array and exclude the ones set to noIndex.
You can also add another field, for now, like “Exclude from sitemap?” and filter on that instead. You can also use a plugin like Computed Fields - Plugins — DatoCMS to derive it from the SEO field… but you really shouldn’t have to jump through hoops like that. I’ll let you know what the devs say as soon as we hear back.
@roger thank you for the reply. We’ll get the clientside filter running. Looking forward to this feature! Would be a great addition to Dato. Haven’t seen any headless CMS providing a “clean” solution to this issue.