withastro/astro · warning
The Sitemap integration requires the `site` astro.config opt
Error message
The Sitemap integration requires the `site` astro.config option. Skipping.
What it means
The Sitemap integration needs an absolute origin to prefix every generated URL, and it takes that origin solely from the top-level site option in astro.config. In its astro:build:done hook it checks config.site; when absent it logs this warning and returns early, so no sitemap-index.xml is written even though the build itself succeeds.
Source
Thrown at packages/integrations/sitemap/src/index.ts:101
let _routes: Array<IntegrationResolvedRoute>;
let config: AstroConfig;
return {
name: PKG_NAME,
hooks: {
'astro:routes:resolved': ({ routes }) => {
_routes = routes;
},
'astro:config:done': async ({ config: cfg }) => {
config = cfg;
},
'astro:build:done': async ({ dir, pages, logger }) => {
try {
if (!config.site) {
logger.warn(
'The Sitemap integration requires the `site` astro.config option. Skipping.',
);
return;
}
const opts = validateOptions(config.site, options);
const {
filenameBase,
filter,
customPages,
customSitemaps,
serialize,
entryLimit,
chunks,
} = opts;
const outFile = `${filenameBase}-index.xml`;
const finalSiteUrl = new URL(config.base, config.site);View on GitHub (pinned to 157c500c38)
Solutions
- Set site in astro.config.mjs: export default defineConfig({ site: 'https://www.example.com', integrations: [sitemap()] });
- If the domain varies by environment, derive it from an env var: site: process.env.SITE_URL (ensure it is set in CI).
- Rebuild and verify dist/sitemap-index.xml is generated.
Example fix
// before
export default defineConfig({
integrations: [sitemap()],
});
// after
export default defineConfig({
site: 'https://www.example.com',
integrations: [sitemap()],
}); Defensive patterns
Strategy: validation
Validate before calling
// fail the build early if site is missing while sitemap is enabled
const config = await import('./astro.config.mjs').then((m) => m.default);
if (config.integrations.some((i) => i.name === 'astro-sitemap') && !config.site) {
throw new Error('sitemap() requires the `site` config option');
} Type guard
const hasSite = (config: { site?: string }): config is { site: string } =>
typeof config.site === 'string' && /^https?:\/\//.test(config.site); Prevention
- Set site in astro.config as part of adding the sitemap integration.
- If SITE_URL comes from an env var, assert it is present before running astro build in CI.
- Check the build log for 'sitemap-index.xml' output or verify dist/ after every production build.
When it happens
Trigger: Running astro build with the sitemap() integration but no site: 'https://example.com' in defineConfig. The astro:build:done hook sees config.site undefined, warns, and skips validateOptions/generateSitemap entirely.
Common situations: New projects or previews deployed to temporary preview URLs (no production domain yet); CI builds where site is meant to come from an env var that was not set; forgetting that dev-only sites still need site for sitemap generation.
Related errors
- No pages found! `${outFile}` not created.
- ${issue.path.join('.')} ${issue.message + '.'}
- No pages found!
- InvalidRedirectDestination
- MissingIndexForInternationalizationError
AI-assisted analysis of withastro/astro@157c500c38 (2026-08-18).
Data as JSON: /api/errors/b2e593915c28be94.
Report an issue: GitHub.