Skip to content

Issue: 404 Error When Using Subfolders in the Blog Directory #64

@sudhirmanglasvam

Description

@sudhirmanglasvam

I am trying to organize my blog posts into subfolders under the /blog directory. The home page correctly lists all posts, but clicking on any post inside a subfolder results in a 404 error. It seems like the routing is broken.

Expected Behavior:

  • Posts inside subfolders should be accessible via their respective URLs.
  • The home page should continue listing all posts correctly.

Current Structure:

/src/content/blog/
  ├── category1/
  │    ├── post-1.md
  │    ├── post-2.md
  ├── category2/
  │    ├── post-3.md
  │    ├── post-4.md
  ├── post-5.md

Questions:

  1. What changes are required in routing or collection settings to make subfolder posts accessible?
  2. Do I need to modify astro.config.mjs or the getCollection() function?
  3. Should I adjust the slug generation logic in pages/blog/[slug].astro to account for subfolders?

I expect to have around 40+ blog posts, so organizing them into subfolders is necessary for better management. Please suggest the best approach to make this work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions