Static page under src/pages
- Included by integration?
- Yes
- What to check
- Confirm the built page is intended for public search.
Install Astro's official sitemap integration, include the right generated routes, and debug missing URLs before submitting the sitemap.
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.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
@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.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.
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.
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.
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.
src/pagesgetStaticPaths()customPages or include that service's sitemap with customSitemaps.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.
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.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.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.i18n option (defaultLocale plus locales) to get hreflang alternates, then verify them and each locale's canonical URL.integrations: [
sitemap({
filter: (page) =>
!page.includes('/preview/') &&
!page.includes('/internal-search/'),
}),
]Open the sitemap index and each child URL listed in it. Confirm HTTPS, the production hostname, valid XML, and successful HTTP responses.
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.
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.
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.
4 questions people ask next, answered from the sources on this page.
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.
The integration includes dynamic routes generated by getStaticPaths(), but it cannot enumerate dynamic routes rendered on demand in SSR mode.
Pass a filter callback to sitemap() in Astro config and return false for URLs that should not be included.
No. A sitemap helps Google discover URLs. Google decides independently whether to crawl and index each page.
Run the free audit, then approve the fixes. Every change can be undone.