Free auditStart free
GuideAstro · XML sitemap

Astro XML sitemap

Install Astro's official sitemap integration, include the right generated routes, and debug missing URLs before submitting the sitemap.

4 min
read
2
sources
Oct 24, 2026
updated
Scaplet Editorial Team
author
In one line

Install @astrojs/sitemap with npx astro add sitemap, set the deployed origin in site in astro.config.mjs, then build and inspect /sitemap-index.xml. The integration includes statically generated routes, including dynamic routes returned by getStaticPaths(), but cannot enumerate dynamic SSR routes. Filter staging or noncanonical URLs, and submit the sitemap index in Search Console.

30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
01How it works

Install the official integration and set the public origin

Astro's @astrojs/sitemap integration writes sitemap files during a build. It needs the public site URL so generated entries use the real canonical origin rather than a local or preview host.
  1. 1

    Add the integration

    Run npx astro add sitemap from the project root. If you manage integrations manually, install @astrojs/sitemap and add sitemap() to the integrations array in astro.config.mjs.

  2. 2

    Set `site` to the production origin

    Add site: 'https://www.example.com' in Astro config. Astro requires it to begin with http:// or https://; use the exact public hostname and protocol that your canonical pages use.

  3. 3

    Build and inspect the output

    Run the production build, then inspect dist/sitemap-index.xml and dist/sitemap-0.xml (Astro writes both to the output directory). After deployment, open /sitemap-index.xml on the production domain and confirm it serves XML.

astro.config.mjs
import { defineConfig } from 'astro/config'
import sitemap from '@astrojs/sitemap'

export default defineConfig({
  site: 'https://www.example.com',
  integrations: [sitemap()],
})

Astro adds sitemap-index.xml and sitemap-0.xml to the output directory; the index links to the numbered files. Astro's docs also suggest a <link rel="sitemap" href="/sitemap-index.xml" /> in your <head>. Link to the index from robots.txt as Sitemap: https://www.example.com/sitemap-index.xml; this helps crawlers discover the right entry point.

03Checklist

Filter exclusions and handle large or multi-app sites

All generated pages are included by default. Pass a filter callback to sitemap() to exclude individual URLs, such as a preview environment or internal search page. For content served by a separate app, use customPages for known page URLs or customSitemaps to add an external sitemap to Astro's index.
First2
Use customSitemaps when another service already owns a section sitemap; avoid copying every URL into Astro config.
entryLimit sets the maximum entries per sitemap file and defaults to 45000; beyond that the integration writes more numbered files (sitemap-1.xml, sitemap-2.xml) and links them from the index. The chunks option (integration v3.7.0 and later) splits by your own logic.
Next1
Astro's docs note changefreq and priority are ignored by Google, and that the integration cannot read a page's source, so those options apply site-wide unless you set per-page values with serialize(). Don't set a site-wide lastmod that does not reflect real changes.
Then1
For localized routes, pass the integration's i18n option (defaultLocale plus locales) to get hreflang alternates, then verify them and each locale's canonical URL.
Exclude non-public routes
integrations: [
  sitemap({
    filter: (page) =>
      !page.includes('/preview/') &&
      !page.includes('/internal-search/'),
  }),
]
04How it works

Validate deployment and Search Console

  1. 1

    Check the deployed response

    Open the sitemap index and each child URL listed in it. Confirm HTTPS, the production hostname, valid XML, and successful HTTP responses.

  2. 2

    Sample URLs from different route families

    Check a static page, a generated dynamic page, a localized route, and any externally served section. Each listed URL should resolve to the canonical page, not a redirect or error.

  3. 3

    Submit the index in Search Console

    Submit sitemap-index.xml under the matching Search Console property, then check the Sitemaps report for errors. Google calls submitting a sitemap "merely a hint": it doesn't guarantee Google will download the sitemap or use it for crawling.

  4. 4

    Diagnose missing important URLs

    If a page is missing from the file, check whether Astro generated it and whether the filter excluded it. If listed but unindexed, use URL Inspection to investigate crawlability, canonical selection, and page quality.

For Google's sitemap expectations, see sitemap submission in Google Search Console and the XML sitemap overview.

Sources · 2

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • astro.build
  • google.com
  1. 01@astrojs/sitemap | Astro Docsdocs.astro.build · checked 2026-10-24
  2. 02Build and submit a sitemap | Google Search Centraldevelopers.google.com · checked 2026-10-24
Questions

Asked a lot.

4 questions people ask next, answered from the sources on this page.

01What is the Astro sitemap URL?

The official integration writes sitemap-index.xml to the output directory, so it is served at /sitemap-index.xml on a root deployment. It links to numbered files such as sitemap-0.xml.

02Why is an Astro dynamic route missing from my sitemap?

The integration includes dynamic routes generated by getStaticPaths(), but it cannot enumerate dynamic routes rendered on demand in SSR mode.

03How do I exclude a URL from the Astro sitemap?

Pass a filter callback to sitemap() in Astro config and return false for URLs that should not be included.

04Does submitting an Astro sitemap guarantee indexing?

No. A sitemap helps Google discover URLs. Google decides independently whether to crawl and index each page.

Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane