The first post made after adding posts to the astro-test project
Posted on 18th May 2026 at 12:00 by Admin
URLs
I want the blog url to be site-url/posts
and each post to be reached via site-url/the-very-first-post
These differences from astro-blog are as much to explore what is enforced by Astro, what is conventional,
and what is entirely up to me as anything else.
Paths
Post files are in src/content/posts. Astro requires src/content. src/content/posts is my choice.
Routing
Astro routing specifies the relationship between file path and browse URL - in both directions.
URL from file path is calculated in src/pages/post/[slug].astro
Implementation
-
Make this file in src/content/posts
-
Create src/content.config.ts
This is identical to astro-blog with the obvious replacements of ‘blog’ with ‘posts’ -
Create src/pages/posts/index.astro
This is identical to astro-blog with the obvious replacements of ‘blog’ with ‘posts’ -
Create src/pages/post/[…slug].astro
This is identical to astro-blog with the obvious replacements of ‘blog’ with ‘posts’
Differences
-
My collection is called ‘posts’. astro-blog’s is ‘blog’
-
My slug prefix is ‘post’. astro-blog’s is ‘blog’. This tiny difference is helpful in sorting things out. Actually it wasn’t, and I’ve changed it to ‘posts’
Category: admin Tags: