The Astro blog features every blog should have are a typed content collection with required frontmatter, draft handling, an RSS feed, a sitemap, per-post meta tags and Open Graph images, tag pages, pagination, reading time, a table of contents on long posts, related posts, and accessible code blocks. Astro gives you the building blocks for all of them with no client JavaScript, but you have to wire each one up.
This checklist groups them by priority, with the Astro API that handles each and a short snippet where it helps. Use it to audit an existing blog or plan a new one.
Key Takeaways
- Start with the content model: a
blogcollection insrc/content.config.tswith a schema that requires title, description and date.- Ship the discoverability basics before anything visual: unique meta tags, sitemap, RSS and canonical URLs.
- Reading time, table of contents and related posts can all be computed at build time, so they cost no JavaScript.
- Search is the one feature that needs client code; Pagefind keeps it static.
- Add features when posts justify them. A ten-post blog doesn’t need pagination or search yet.
Must-have: the content foundation
A typed blog collection
Every other feature reads from this. Define the collection with a schema so a post missing a title or date fails the build instead of rendering broken:
// src/content.config.ts
import { defineCollection } from 'astro:content';
import { glob } from 'astro/loaders';
import { z } from 'astro/zod';
const blog = defineCollection({
loader: glob({ pattern: '**/*.{md,mdx}', base: './src/content/blog' }),
schema: ({ image }) =>
z.object({
title: z.string().max(70),
description: z.string().max(170),
pubDate: z.coerce.date(),
updatedDate: z.coerce.date().optional(),
cover: image().optional(),
tags: z.array(z.string()).default([]),
draft: z.boolean().default(false),
}),
});
export const collections = { blog };
image() validates that cover images exist and lets Astro optimize them. The max limits keep titles and descriptions within search snippet lengths. The Content Collections guide covers schemas in depth.
Drafts that never ship
Filter drafts in one helper and use it everywhere: post routes, index, tags, RSS and sitemap.
// src/lib/posts.ts
import { getCollection } from 'astro:content';
export async function getPublishedPosts() {
const posts = await getCollection('blog', ({ data }) =>
import.meta.env.DEV || !data.draft
);
return posts.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
}
Drafts stay visible in astro dev so you can preview them, and disappear from production builds. Using one function means a draft can’t leak through a route you forgot.
MDX for posts that need components
Plain Markdown handles most posts. Add @astrojs/mdx when you want callouts, embeds or interactive demos inside a post. In Astro 7, .md files go through Sätteri, Astro’s built-in Markdown processor, by default; if you rely on remark or rehype plugins, check the Astro Markdown docs for how to configure the processor that runs them.
Must-have: discoverability
Unique meta tags on every post
Title, description, canonical URL and Open Graph tags, rendered from frontmatter by one head component. The reusable meta tags component covers the full set.
Sitemap
npx astro add sitemap
Set site in astro.config.mjs and sitemap-index.xml is generated on every build. Exclude utility pages (thank-you, search) with the filter option.
RSS feed
Feed readers and automated newsletters still depend on RSS. @astrojs/rss and a single src/pages/rss.xml.js endpoint generate it from the same collection. The Astro RSS guide includes full-content feeds and autodiscovery links.
Structured data
A BlogPosting JSON-LD block with headline, dates and author on each post. It’s a few lines in the post layout and gives search engines and AI tools an unambiguous summary.
Open Graph images
A per-post share image with the title on it, generated at build time with Satori. Without one, every shared link looks identical in Slack and LinkedIn.
Must-have: reading experience
Readable typography
A content width around 65 to 75 characters, a base font size of at least 16 px, generous line height and clear heading sizes. If you use Tailwind CSS, the typography plugin’s prose classes give rendered Markdown sensible defaults in one class.
Optimized images
Images in Markdown that use relative paths () are processed by Astro’s image pipeline automatically: resized, converted and given dimensions to prevent layout shift. Images referenced from public/ aren’t, so keep post images next to the post.
Code blocks
Astro highlights code with Shiki at build time, so there’s no highlighting script in the browser. Add a dual light and dark theme if your site has a dark mode, and a copy button for tutorial-heavy blogs. The copy code button component adds one with a small script.
Dates that are honest
Show the publish date, and an “Updated” date when updatedDate is set. Readers and search engines both use it to judge freshness.
Should-have: navigation between posts
Tag pages
Generate one page per tag with getStaticPaths():
---
// src/pages/tags/[tag].astro
import { getPublishedPosts } from '../../lib/posts';
export async function getStaticPaths() {
const posts = await getPublishedPosts();
const tags = [...new Set(posts.flatMap((p) => p.data.tags))];
return tags.map((tag) => ({
params: { tag: tag.toLowerCase().replace(/\s+/g, '-') },
props: { tag, posts: posts.filter((p) => p.data.tags.includes(tag)) },
}));
}
const { tag, posts } = Astro.props;
---
<h1>Posts tagged {tag}</h1>
<ul>
{posts.map((post) => <li><a href={`/blog/${post.id}/`}>{post.data.title}</a></li>)}
</ul>
Keep the tag list short and consistent. Fifty tags with one post each make thin pages that help nobody. The tags and categories guide covers slugs and index pages.
Pagination
Once the index passes 20 or so posts, paginate with Astro’s paginate() helper in getStaticPaths(). It generates /blog/2/, /blog/3/ and so on with previous and next URLs. The pagination guide shows the full route.
Previous and next links
At the end of each post, link to the adjacent posts by date. It’s computed from the sorted list at build time and keeps readers moving.
Related posts
Score other posts by shared tags and show the top three. Like everything else here, it runs at build time:
// src/lib/related.ts
import type { CollectionEntry } from 'astro:content';
export function relatedPosts(
current: CollectionEntry<'blog'>,
all: CollectionEntry<'blog'>[],
limit = 3,
) {
return all
.filter((p) => p.id !== current.id)
.map((p) => ({
post: p,
score: p.data.tags.filter((t) => current.data.tags.includes(t)).length,
}))
.filter((r) => r.score > 0)
.sort((a, b) => b.score - a.score)
.slice(0, limit)
.map((r) => r.post);
}
The related posts tip adds a date fallback for posts with no shared tags.
Should-have: long-post features
Reading time
Count words in post.body and divide by about 200 to 250 words per minute. It sets expectations and is computed once per build. The reading time tip shows both an inline helper and a remark plugin approach.
Table of contents
render(post) returns a headings array with each heading’s depth, text and slug. Map the H2s and H3s to a list of anchor links; no plugin required. The table of contents tip adds active-section highlighting with a small script.
Heading anchor links
Readers share links to sections. Astro already gives every heading an id; adding a visible link icon next to each heading makes them easy to copy.
Nice-to-have: growth and engagement
| Feature | Approach in Astro | Client JS |
|---|---|---|
| Search | Pagefind index built after astro build |
Yes, loaded on the search page |
| Newsletter signup | A plain HTML form posting to your email provider | None required |
| Comments | Giscus (GitHub Discussions) loaded with client:visible or on click |
Yes, deferred |
| Series | A series field in frontmatter and a list component |
None |
| Author pages | An authors collection and reference('authors') in the post schema |
None |
| Privacy-friendly analytics | A small script from Plausible, Umami or similar | Small |
| Dark mode | CSS variables plus a tiny inline toggle script | Small |
Search is the one feature on this list worth delaying until you have enough posts that scrolling the index stops working. Pagefind runs as a post-build step and loads its index only when someone searches. The Pagefind search guide has the setup.
Before launch
- Every post has a unique title and description under the schema limits.
- Drafts are excluded from the index, tags, RSS and sitemap.
siteis set, and canonical URLs match the URLs your host serves.- The RSS feed validates and has an autodiscovery link.
- A custom 404 page exists and links back to the blog.
- Images in posts are local and processed by Astro.
- A Lighthouse run on a long post shows no layout shift from images or fonts.
If you’d rather start with these features already built, the Astro blog and editorial themes are complete Astro projects with post layouts you can extend, and the content docs explain how their collections are organized. For a step-by-step build from an empty project, see build a blog with Astro.
FAQ
Is Astro good for blogs?
Yes. Astro was designed for content sites: Markdown and MDX are built in, Content Collections validate frontmatter, and pages ship as static HTML with no JavaScript by default, which makes blogs fast and easy to host anywhere.
How do I add tags to an Astro blog?
Add a tags array to the collection schema, then create src/pages/tags/[tag].astro with getStaticPaths() returning one path per unique tag and the posts that use it as props.
How do I hide draft posts in Astro?
Add draft: z.boolean().default(false) to the schema and pass a filter to getCollection() that excludes drafts in production. Use the same helper in every route, including RSS.
Does an Astro blog need a CMS?
No. Markdown files in the repository work well for developers and small teams. Add a Git-based or headless CMS when non-technical writers need an editor interface.
How do I add search to an Astro blog without a server?
Use Pagefind. It indexes the built HTML after astro build and serves a static index that the search UI loads on demand, so it works on any static host.