Pages and routing
Create routes with files
Map files under src/pages to URLs without creating a separate route table.
8 minute lesson
Files under src/pages/ become public routes.
src/pages/index.astro → /
src/pages/about.astro → /about/
src/pages/docs/install.astro → /docs/install/
Astro uses the file and folder names as the route table. You do not register these pages in another configuration file.
Pages can be .astro, Markdown, MDX when configured, HTML, or endpoint files such as .ts. The extension affects how the route produces its response.
Keep the hierarchy obvious. If /docs/install/ fails, you should be able to find its source without searching the entire project.
Avoid creating two page files that compete for the same route. Also remember that your host may normalize trailing slashes or filenames differently from development.
Create src/pages/contact.astro and src/pages/guides/index.astro. Open both URLs, then run a production build and find their generated output.
Lesson completed