{"record":{"id":"c1faf08265fcc8c6","repo":"withastro/astro","slug":"getstaticpaths-ignored-in-dynamic-page-colors","errorCode":null,"errorMessage":"getStaticPaths() ignored in dynamic page ${colors.bold(rootRelativePath(settings.config.root, fileURL, true))}. Add `export const prerender = true;` to prerender the page as static HTML during the build process.","messagePattern":"getStaticPaths\\(\\) ignored in dynamic page (.+?)\\. Add `export const prerender = true;` to prerender the page as static HTML during the build process\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro/src/vite-plugin-routes/index.ts","lineNumber":256,"sourceCode":"\t\t\tconst fileIsEndpoint = isEndpoint(fileURL, settings);\n\t\t\tif (!(fileIsPage || fileIsEndpoint)) return;\n\t\t\tconst route =\n\t\t\t\tthis.environment.mode === 'build'\n\t\t\t\t\t? getRouteByFilename().get(filename)\n\t\t\t\t\t: findRouteByFilename(filename);\n\n\t\t\tif (!route) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// `getStaticPaths` warning is just a string check, should be good enough for most cases\n\t\t\tif (\n\t\t\t\t!route.prerender &&\n\t\t\t\tcode.includes('getStaticPaths') &&\n\t\t\t\t// this should only be valid for `.astro`, `.js` and `.ts` files\n\t\t\t\tKNOWN_FILE_EXTENSIONS.includes(extname(filename))\n\t\t\t) {\n\t\t\t\tlogger.warn(\n\t\t\t\t\t'router',\n\t\t\t\t\t`getStaticPaths() ignored in dynamic page ${colors.bold(\n\t\t\t\t\t\trootRelativePath(settings.config.root, fileURL, true),\n\t\t\t\t\t)}. Add \\`export const prerender = true;\\` to prerender the page as static HTML during the build process.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst { meta = {} } = this.getModuleInfo(id) ?? {};\n\t\t\treturn {\n\t\t\t\tcode,\n\t\t\t\tmap: null,\n\t\t\t\tmeta: {\n\t\t\t\t\t...meta,\n\t\t\t\t\tastro: {\n\t\t\t\t\t\t...(meta.astro ?? createDefaultAstroMetadata()),\n\t\t\t\t\t\tpageOptions: {\n\t\t\t\t\t\t\tprerender: route.prerender,\n\t\t\t\t\t\t},","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/vite-plugin-routes/index.ts#L238-L274","documentation":"vite-plugin-routes does a literal string scan for `getStaticPaths` in route module code. If the route is not prerendered (e.g. output: 'server' without opt-in), getStaticPaths is dead code Astro never calls, so the plugin warns and points you to `export const prerender = true;` to make it effective. The check is a plain substring match limited to .astro/.js/.ts route files.","triggerScenarios":"A page exports getStaticPaths while its route resolves to server-rendered: output: 'server' or 'hybrid' without `export const prerender = true`, or an explicit prerender = false in the same file. Also fires as a false positive when the literal text appears in a comment or string inside a dynamic route file.","commonSituations":"Copying a static page into a project defaulted to server output; flipping a page to dynamic but leaving getStaticPaths behind; mentioning getStaticPaths in a comment of a server route and getting the warning anyway.","solutions":["Add `export const prerender = true;` to the page if it should be static","Delete getStaticPaths if the page is meant to be dynamic — params then come from the request, not static generation","Set output: 'static' in astro.config.mjs if the majority of pages should prerender","For false positives, reword the comment/string so it no longer contains the literal token"],"exampleFix":"// before  src/pages/[slug].astro (output: 'server')\nexport async function getStaticPaths() { /* ignored: page is dynamic */ }\n\n// after\nexport const prerender = true;\nexport async function getStaticPaths() { /* now runs at build */ }","handlingStrategy":"validation","validationCode":"# List route files containing getStaticPaths that lack the prerender opt-in\nfor f in $(grep -rl 'getStaticPaths' src/pages --include='*.astro'); do\n  grep -q 'prerender = true' \"$f\" || echo \"missing prerender: $f\"\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat getStaticPaths and `export const prerender = true` as an inseparable pair in code review","Avoid the literal token getStaticPaths in comments/strings of dynamic routes (the warning is a substring match)","Decide output mode per project early and audit pages copied between projects"],"tags":["astro","routing","prerender","getstaticpaths","static-generation"],"backgroundTag":"prerender-config-mismatch","analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}