Skip to content

Commit

Permalink
Clarify route precedence in routing.mdx
Browse files Browse the repository at this point in the history
  • Loading branch information
mb21 committed Jan 23, 2024
1 parent 8047fe6 commit 976b98e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/content/docs/en/core-concepts/routing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,9 @@ It's possible for multiple defined routes to attempt to build the same URL path.
- [...slug].astro
</FileTree>

Astro needs to know which route should be used to build the page. To do so, it sorts them according to the following rules in order:
Astro needs to know which route should be used to build the page. To do so, it sorts the routes according to the following rules (if two rules apply, the one that comes first in the following list takes precedence):

- Routes with more path segments will take precedence over less specific routes. In the example above, all routes under `/posts/` take precedence over `/[...slug].astro` at the root.
- Routes with more path segments will take precedence over routes with fewer path segments. In the example above, all routes under `/posts/` take precedence over `/[...slug].astro` at the root.
- Static routes without path parameters will take precedence over dynamic routes. E.g. `/posts/create.astro` takes precedence over all the other routes in the example.
- Dynamic routes using named parameters take precedence over rest parameters. E.g. `/posts/[page].astro` takes precedence over `/posts/[...slug].astro`.
- Pre-rendered dynamic routes take precedence over server dynamic routes.
Expand Down

0 comments on commit 976b98e

Please sign in to comment.