Every page in src/pages/ becomes a page on your website. See the existing page such as index.mdx for reference.
How page names become URLs
| File | Website address |
|---|---|
src/pages/index.mdx |
/ |
src/pages/about.mdx |
/about |
src/pages/services.mdx |
/services |
src/pages/team/alex.mdx |
/team/alex |
Use lowercase filenames with hyphens, such as work-with-me.mdx.
Create an MDX page
Use MDX when your page is mostly text, headings, lists, images, and a few components.
Create src/pages/services.mdx:
---
layout: ../layouts/PageLayout.astro
title: Services
description: Learn about the services I offer.
---
import Button from "../components/Button.astro";
# Services
I help people create simple and useful websites.
## Website design
Add a short description of your service here.
<Button href="/contact">Contact me</Button>
You can now visit /services.
The beginning part between the --- lines is called frontmatter:
layoutadds the shared header, footer, page styles, and page information.titleis the title shown in the browser and search results.descriptionis a short summary of the page.topSpacingis optional. Set it tofalsewhen the page’s first component provides its own top spacing.
Imports go below the frontmatter and before the component is used.
Create a blog post
Regular pages go in src/pages/. Blog posts go in src/content/blog/.
Create a file such as src/content/blog/my-first-post.mdx:
---
title: My first post
description: A short introduction to my first blog post.
pubDate: 2026-08-01
---
## My first section
Write your post here.
The post will appear at /blog/my-first-post. Start blog post sections with ## because the blog layout already shows the post title as the main heading.
Keep blog post files directly inside src/content/blog/.
Add page-specific head information
The shared layouts include a head slot for unusual page-specific tags:
<Fragment slot="head">
<meta name="category" content="events" />
</Fragment>Most pages do not need this. Use the existing title, description, canonical, social image, and robots options before adding tags by hand.
Before you publish
Check that:
- The filename creates the URL you want.
- The title and description explain the page clearly.
- The page has one main
#or<h1>heading. - Links do not end with a slash.
- The page is in the menu if visitors need it there.
- Images have useful alternative text.