at.ncvp.me

First Astro project with 'pages' and 'posts' collections

The very first post

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

  1. Make this file in src/content/posts

  2. Create src/content.config.ts
    This is identical to astro-blog with the obvious replacements of ‘blog’ with ‘posts’

  3. Create src/pages/posts/index.astro
    This is identical to astro-blog with the obvious replacements of ‘blog’ with ‘posts’

  4. Create src/pages/post/[…slug].astro
    This is identical to astro-blog with the obvious replacements of ‘blog’ with ‘posts’

Differences

Category: admin Tags:

Rendered by src/pages/posts/[slug].astro