Skip to content

buildSitemapDocuments

buildSitemapDocuments(result, options): SitemapDocument[]

Renders a site’s sitemap as the set of documents it actually needs — one when it fits, an index plus shards when it does not.

Prefer this to buildSitemapXml as the default. Under the caps it returns exactly one document whose xml is byte-identical to that function’s output, so nothing is given up by reaching for it first; past them it is the difference between a sitemap and an exception. A function only large sites call is a function only large sites discover, and they discover it by failing.

Pure: data in, documents out. No I/O, no fetch, no environment access — so it is equally callable from a request handler and from a static build script. Serving the documents at their paths is still your job; the one thing this function needs to know about serving is the paths themselves, because an index, unlike a single sitemap, is not self-contained — it names the URLs its shards are served at, so those paths have to be agreed here.

SitemapResult

BuildSitemapDocumentsOptions

SitemapDocument[]

when a single node’s own URLs exceed one file, or when the index itself would need to reference more sitemaps than the protocol allows. Neither is reachable at the default caps.