Routes & ship · Lesson 16 of 22 · 20 min
Make it yours and keep going
Turn the course project into your own site, then level up with tag pages, RSS, and images.
You built and shipped a real Astro site. Here’s what you used:
| Skill | Where you used it |
|---|---|
| Project setup | npm create astro, dev, build, preview |
| Components and props | Header, Nav, Footer, Card, PostCard |
| Styles | global.css variables plus scoped <style> tags |
| Slots | BaseLayout default slot, Section named slot |
| JSON data | services.json, nav.json |
| Markdown and frontmatter | About page, blog posts |
| Content collections | content.config.ts, getCollection, render |
| Routing | index, folders, [id].astro, 404.astro |
| Deploy | GitHub plus Vercel |
Make it yours in one sitting
Swap Sunday Supper for a real business. Here’s the full list of files to touch:
BaseLayout.astroandFooter.astro: change the business nameglobal.css: change the five color variablesindex.astro: rewrite the hero headline and lineservices.json: your real services and pricesabout.md: your storysrc/content/blog/: delete the sample posts, write one real onegit push
That’s it. The structure stays the same.
Challenge 1: Tag pages
Make /blog/tags/menu list every post tagged “menu”.
Show a solution
src/pages/blog/tags/[tag].astro
---
import BaseLayout from '../../../layouts/BaseLayout.astro';
import PostCard from '../../../components/PostCard.astro';
import { getCollection } from 'astro:content';
export async function getStaticPaths() {
const posts = await getCollection('blog', ({ data }) => !data.draft);
const tags = [...new Set(posts.flatMap((post) => post.data.tags))];
return tags.map((tag) => ({
params: { tag },
props: {
posts: posts.filter((post) => post.data.tags.includes(tag)),
},
}));
}
const { tag } = Astro.params;
const { posts } = Astro.props;
---
<BaseLayout title={`Posts tagged ${tag}`}>
<div class="container">
<h1>Tagged: {tag}</h1>
{posts.map((post) => <PostCard post={post} />)}
</div>
</BaseLayout>
Then turn each tag on the post page into a link: <a href={/blog/tags/${tag}}>{tag}</a>.
Challenge 2: RSS feed
Let people follow your blog in a feed reader. Install the official package:
npm install @astrojs/rss
Show a solution
Make sure site is set in astro.config.mjs (lesson 15). Then:
src/pages/rss.xml.js
import rss from '@astrojs/rss';
import { getCollection } from 'astro:content';
export async function GET(context) {
const posts = await getCollection('blog', ({ data }) => !data.draft);
return rss({
title: 'Sunday Supper Co.',
description: 'Recipes, menus, and kitchen notes.',
site: context.site,
items: posts.map((post) => ({
title: post.data.title,
description: post.data.description,
pubDate: post.data.pubDate,
link: `/blog/${post.id}/`,
})),
});
}
A .js file in pages/ that exports GET is an endpoint. It builds to /rss.xml.
Challenge 3: Optimized images
Put a photo in src/assets/ (not public/) and use Astro’s <Image /> component. It resizes and converts images to modern formats at build time.
---
import { Image } from 'astro:assets';
import hero from '../assets/hero.jpg';
---
<Image src={hero} alt="A long table set for dinner" width={1200} />
Add a cover image field to your blog schema next. Look up the image() helper in the Astro docs.
Challenge 4: Sitemap
npx astro add sitemap
astro add installs the integration and updates your config for you. Rebuild and look for sitemap-index.xml in dist/.
Where to learn more
- docs.astro.build, the official docs, which are excellent
- The Astro Discord, linked from the docs, for questions
- astro.build/themes to see how others structure bigger sites