{"record":{"id":"b2e593915c28be94","repo":"withastro/astro","slug":"the-sitemap-integration-requires-the-site-astro","errorCode":null,"errorMessage":"The Sitemap integration requires the `site` astro.config option. Skipping.","messagePattern":"The Sitemap integration requires the `site` astro\\.config option\\. Skipping\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/integrations/sitemap/src/index.ts","lineNumber":101,"sourceCode":"\tlet _routes: Array<IntegrationResolvedRoute>;\n\tlet config: AstroConfig;\n\n\treturn {\n\t\tname: PKG_NAME,\n\n\t\thooks: {\n\t\t\t'astro:routes:resolved': ({ routes }) => {\n\t\t\t\t_routes = routes;\n\t\t\t},\n\n\t\t\t'astro:config:done': async ({ config: cfg }) => {\n\t\t\t\tconfig = cfg;\n\t\t\t},\n\n\t\t\t'astro:build:done': async ({ dir, pages, logger }) => {\n\t\t\t\ttry {\n\t\t\t\t\tif (!config.site) {\n\t\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\t'The Sitemap integration requires the `site` astro.config option. Skipping.',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst opts = validateOptions(config.site, options);\n\n\t\t\t\t\tconst {\n\t\t\t\t\t\tfilenameBase,\n\t\t\t\t\t\tfilter,\n\t\t\t\t\t\tcustomPages,\n\t\t\t\t\t\tcustomSitemaps,\n\t\t\t\t\t\tserialize,\n\t\t\t\t\t\tentryLimit,\n\t\t\t\t\t\tchunks,\n\t\t\t\t\t} = opts;\n\t\t\t\t\tconst outFile = `${filenameBase}-index.xml`;\n\t\t\t\t\tconst finalSiteUrl = new URL(config.base, config.site);","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/withastro/astro/blob/157c500c38faa7ecf1251adbaeefcd109470d75c/packages/integrations/sitemap/src/index.ts#L83-L119","documentation":"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.","triggerScenarios":" 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.","commonSituations":" 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.","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."],"exampleFix":"// before\nexport default defineConfig({\n  integrations: [sitemap()],\n});\n\n// after\nexport default defineConfig({\n  site: 'https://www.example.com',\n  integrations: [sitemap()],\n});","handlingStrategy":"validation","validationCode":"// fail the build early if site is missing while sitemap is enabled\nconst config = await import('./astro.config.mjs').then((m) => m.default);\nif (config.integrations.some((i) => i.name === 'astro-sitemap') && !config.site) {\n  throw new Error('sitemap() requires the `site` config option');\n}","typeGuard":"const hasSite = (config: { site?: string }): config is { site: string } =>\n  typeof config.site === 'string' && /^https?:\\/\\//.test(config.site);","tryCatchPattern":null,"preventionTips":["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."],"tags":["sitemap","site-config","seo","build","config"],"backgroundTag":"missing-site-config","analyzedSha":"157c500c38faa7ecf1251adbaeefcd109470d75c","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}