Skip to content

Discoverability · Astro

How to add a sitemap.xml in Astro

A sitemap is how you tell a search engine which pages exist and when they last changed, rather than waiting for every one of them to be found by following links. Without it, pages that are not linked prominently can go months before they are crawled at all.

The fix for Astro

13x detects your framework from the response and hands you this version rather than the generic one — below 50% confidence it hedges and gives you the generic one instead.

Add the official sitemap integration:

bash code
npx astro add sitemap
js code
// astro.config.mjs
import sitemap from "@astrojs/sitemap";

export default defineConfig({
  site: "https://example.com", // required, the integration is a no-op without it
  integrations: [sitemap()],
});

The output is /sitemap-index.xml. Point robots.txt at that, not sitemap.xml.

On a different stack? The general version of this fix explains what 13x checks and why it matters, without assuming a framework.

Check your Astro site

113 deterministic checks against your live URL, in about 30 seconds. Framework detected from the response, so every fix comes back in the form your stack actually uses.

No signup. Results in 30 seconds.

The same fix, other stacks