Now that the site is running, let’s create a simple new page to understand how Astro works.
1
Create a New Page File
Create a new file at src/pages/about.astro:
src/pages/about.astro
---import Layout from "../layouts/Layout.astro";---<Layout title="About RobTop Games" description="Learn more about RobTop Games"> <section> <div class="container"> <div class="row"> <div class="col-md-8 mx-auto text-center text-white py-5"> <h1 class="mb-4">About RobTop Games</h1> <p class="lead"> RobTop Games is the creator of Geometry Dash and other popular rhythm-based platformer games. </p> </div> </div> </div> </section></Layout>
Files in src/pages/ automatically become routes. This file creates the /about route.
2
View Your New Page
Navigate to your new page in the browser:
http://localhost:4321/about
You should see your new About page with the Layout wrapper (header and footer) applied automatically.
The Layout.astro component provides the base structure for all pages. It accepts several props:
src/layouts/Layout.astro
interface Props { title: string; // Page title (required) description: string; // Meta description (required) image?: string; // OG image (optional) canonicalURL?: string; // Canonical URL (optional)}
Example usage:
<Layout title="My Page Title" description="This is what appears in search results" image="/assets/img/og-image.png"> <!-- Your page content --></Layout>