Skip to main content

Pages for Astros

Astro pages are files in the src/pages folder that become routes, built from .astro components. A component has a frontmatter script fence for logic and an HTML-like template below it, with scoped styles and imported assets. Layouts wrap pages to share headers, footers and metadata.

Stage: Basics · Part of the Astro roadmap · Last reviewed 19 November 2026

What to learn in Pages

Pages interview questions

How does routing work in Astro?

Astro uses file-based routing. Each .astro, .md or .mdx file in src/pages becomes a URL matching its path, so about.astro becomes /about. Dynamic routes use bracketed names such as [slug].astro, with getStaticPaths telling the build which pages to generate.

What is the code fence in an Astro component?

The code fence is the block between two triple-dash lines at the top of an .astro file. It runs on the server or at build time, never in the browser, and can import components, fetch data and define variables that the template below then uses.

Where Pages fits in the Astro roadmap

Pages belongs to the Basics stage (beginner level), which takes about 13 hours. Pages and components.

Back to the full Astro roadmap