File-Based Routing in Astro
From the Astro cheat sheet · Routing & Pages · verified Jul 2026
File-Based Routing
text
src/pages/
├── index.astro → /
├── about.astro → /about
├── blog/
│ ├── index.astro → /blog
│ ├── post-1.astro → /blog/post-1
│ └── [slug].astro → /blog/:slug
├── api/
│ └── posts.json.ts → /api/posts.json
└── _hidden.astro → Not routed (underscore)✅ Each file in src/pages/ becomes a route automatically
💡 index.astro maps to parent directory path
🔍 Prefix with _ to exclude from routing
⚡ .astro, .md, .mdx, .html, .js, .ts all supported
routingfile-basedpages