...

/

Creating Pages with Astro’s File-Based Routing

Creating Pages with Astro’s File-Based Routing

Learn about Astro’s file-based routing, URL generation, static routes, and navigation between them.

We'll cover the following...

Astro uses file-based routing to generate URLs. This means that URLs will be generated based on the name of the file. All routes must be created inside the src/pages folder. To get a better understanding of how routes are generated, take a look at the table below:

File

Generated Route

src/pages/index.astro

domain.com/

src/pages/contact.astro

domain.com/contact

src/pages/contact/index.astro

domain.com/contact

src/pages/contact/john.astro

domain.com/contact/john

As we can see, each file inside the src/pages folder represents a specific route in our application:

  • src/pages/index.astro: It generates the root URL (domain.com/). This file represents the landing page of our ...