# Astro XML sitemap

> Install Astro

Canonical: https://scaplet.com/seo/astro/xml-sitemap

Guide 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 with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fastro%2Fxml-sitemap%20(%22Astro%20XML%20sitemap%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fastro%2Fxml-sitemap%20(%22Astro%20XML%20sitemap%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fastro%2Fxml-sitemap%20(%22Astro%20XML%20sitemap%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fastro%2Fxml-sitemap%20(%22Astro%20XML%20sitemap%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

On this page

## 4 parts, 4 minutes.

1. [Install the official integration and set the public origin 01](#install-the-official-integration-and-set-the-public-origin)
2. [Know which Astro routes can appear 02](#know-which-astro-routes-can-appear)
3. [Filter exclusions and handle large or multi-app sites 03](#filter-exclusions-and-handle-large-or-multi-app-sites)
4. [Validate deployment and Search Console 04](#validate-deployment-and-search-console)

_01_How 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.

_02_Route generation determines sitemap coverage

## Know which Astro routes can appear

Route type

### Static page under `src/pages`

Included by integration?

Yes

What to check

Confirm the built page is intended for public search.

Route type

### Dynamic route generated with `getStaticPaths()`

Included by integration?

Yes

What to check

Check the generated paths and make sure each should be indexed.

Route type

### Dynamic route rendered on demand in SSR mode

Included by integration?

No

What to check

Provide a sitemap from another source or create a route inventory that can enumerate the public URLs.

Route type

### URL from another app or CMS on the same domain

Included by integration?

Not automatically

What to check

Add it using `customPages` or include that service's sitemap with `customSitemaps`.

Route type

### Preview, private, duplicate, or utility route

Included by integration?

No: all pages are included by default

What to check

Use the integration `filter` option to exclude URLs that should not be published.

For a site with 10,000 generated pages, inspect the built sitemap rather than assuming every content record became a route. `getStaticPaths()` controls which paths are actually generated; a sitemap cannot list pages your build never emits.

**Don't list every route by default**A sitemap is most useful when it lists canonical, successful pages that matter in search. Filter drafts, preview hosts, [duplicate URL](/seo-issues/duplicate-pages) variants, and pages that should be `noindex`.

_03_Checklist

## 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](/glossary/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.

First_2_
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](/glossary/xml-sitemap) 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.

Next_1_
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.

Then_1_
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](/glossary/canonical-url).

Exclude non-public routes

```
integrations: [ sitemap({ filter: (page) => !page.includes('/preview/') && !page.includes('/internal-search/'), }), ]
```

_04_How 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](/glossary/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](/glossary/google-search-console) property, then check the [Sitemaps report](/glossary/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](/seo/google-search-console/sitemap-submission) and the [XML sitemap overview](/glossary/xml-sitemap).

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 Docs](https://docs.astro.build/en/guides/integrations-guide/sitemap/) docs.astro.build · checked 2026-10-24
2. 02 [Build and submit a sitemap | Google Search Central](https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap) developers.google.com · checked 2026-10-24

Questions

## Asked a lot.

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

_01_ What 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`.

_02_ Why 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.

_03_ How 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.

_04_ Does submitting an Astro sitemap guarantee indexing?

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

## Keep learning

[All platform guides](/seo)

[Learn Astro SEO Frameworks](/seo/astro) [Related Google Search Console Crawling and indexing](/glossary/google-search-console) [Read next Astro robots.txt Frameworks](/seo/astro/robots-txt) [Do Run a free site audit Free, about two minutes](/site-audit)

Nearby in platform guides
[BigCommerce SEO](/seo/bigcommerce) [BigCommerce page speed](/seo/bigcommerce/page-speed)

More in Astro SEO
[Astro 404 page](/seo/astro/404) [Astro Google Analytics](/seo/astro/google-analytics) [Astro redirects](/seo/astro/redirects) [Astro robots.txt](/seo/astro/robots-txt) [Astro XML sitemap](/seo/astro/xml-sitemap)

Terms on this page
[Internal search](/glossary/internal-search) [XML sitemap](/glossary/xml-sitemap) [Canonical URL](/glossary/canonical-url) [HTTPS](/glossary/https) [Google Search Console](/glossary/google-search-console) [Sitemaps report](/glossary/sitemaps-report)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

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

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
