Sitemap
Automatic sitemap generation
The CMS includes automatic sitemap generation via the @astrojs/sitemap integration. The sitemap is generated as part of every production build and requires no manual maintenance. As your content grows or changes state, the sitemap stays in sync automatically.
Setup
The only required configuration is the SITE environment variable in your .env file. This sets the canonical base URL used for all sitemap entries:
SITE=https://example.comWithout this value set, the sitemap will not generate correctly. See Configuration for more details on environment variables.
The sitemap is built from all pages that are statically generated during the production build. Because only entries in a PUBLISHED system state are included in static builds, unpublished and draft content is never rendered, and therefore never appears in the sitemap. No additional filtering is needed on your part.
Exclude Routes
Some routes, such as the CMS itself, are excluded from the sitemap by default. To exclude additional routes from the sitemap, update the excludeFromSitemap array in astro.config.mjs:
const excludeFromSitemap = [ ... '/your-private-route']Any page whose URL contains one of the listed strings will be omitted from the generated sitemap. Partial matches work: /your-private-route will exclude /your-private-route/nested as well.