Astro shows “Prerendered route generates the same path as another route” when two route files would both write the same URL in a static build. The message names both routes and says one “conflicts with higher priority route”, and the hint is: “Ensure” the two routes “don’t generate the same static paths.” Usually a dynamic route’s getStaticPaths() returns a value that a static file already covers, or two dynamic routes overlap.
Key Takeaways
- Two files can’t both build
/blog/featured/.- Typical case:
blog/featured.astroplusblog/[slug].astrowith a post whose id isfeatured.- Fix by renaming one, filtering
getStaticPaths(), or moving one route to another folder.- Overlapping rest params (
[...path]) and named params are another common source.
Example 1: static page vs dynamic route
src/pages/blog/featured.astro
src/pages/blog/[slug].astro # getStaticPaths returns "featured" too
Filter the dynamic route so it skips reserved names:
const reserved = new Set(['featured', 'archive', 'tags']);
export async function getStaticPaths() {
const posts = await getCollection('blog');
return posts
.filter((post) => !reserved.has(post.id))
.map((post) => ({ params: { slug: post.id }, props: { post } }));
}
Or rename the post file so its id no longer clashes.
Example 2: two dynamic routes
src/pages/[category]/index.astro # builds /design/, /code/
src/pages/[page]/index.astro # builds /1/, /2/ and accidentally /design/
Give one of them a prefix (src/pages/page/[page].astro), or make sure their param values can never overlap.
Example 3: rest params
src/pages/docs/[...path].astro # can build /docs/install/
src/pages/docs/install.astro
Remove install from the rest route’s paths, or delete the static file and let the collection handle it.
Example 4: pagination
[...page].astro builds page one at the parent path. If you also have an index.astro in the same folder, both claim it. Keep one setup: index.astro plus [page].astro (whose pages start at /1/), or [...page].astro on its own.
The rule of thumb: with [...page].astro, delete index.astro in that folder.
See which wins
Astro’s route priority rules decide which route serves a URL when patterns overlap: static beats dynamic, named params beat rest params, and so on. The Astro routing guide lists them in order. During a static build, though, Astro refuses to build two pages for one path, which is what this error protects.
Related: No static path found for requested path and getStaticPaths() required. The routing reference documents priority.
FAQ
Why didn’t this error appear in development?
The dev server renders on request and simply picks the higher-priority route. The build generates every path up front and detects the duplicate.
Can I let one route override the other on purpose?
Not for prerendered pages. Filter the lower-priority route’s getStaticPaths() so it doesn’t generate the duplicate.