Keeping Markdown content tidy as a site grows requires a predictable archive strategy. Below is a pragmatic approach you can drop into any App Router project.
Goals for a good archive
- Make it easy to browse by year and month.
- Keep URL stability as content moves.
- Require minimal runtime logic; lean on filesystem metadata when possible.
- Remain compatible with static generation and incremental revalidation.
Recommended folder layout
Organize content by domain, not date. Example:
content/
blog/
scalable-nextjs-blog-archive.md
improving-devex-with-contentlayer.md
...
Date lives in frontmatter, not in the filename. This allows renames without breaking URLs (because the slug can stay the same) and keeps the folder structure flat for fast lookups.
Building the archive index
- Read all Markdown files.
- Parse frontmatter for
date,title,category,author,excerpt. - Group posts by year and month in memory.
- Sort years, months, and posts descending by date.
The helper should skip invalid dates gracefully so a single bad file does not break the archive page.
UX tips for the archive page
- Present a year heading with a badge for each month and a post count.
- Show title, author, and published date; include a short excerpt for quick scanning.
- Link back to the main blog page for discovery.
Performance considerations
- Use synchronous filesystem reads only at build time. If you enable ISR, cache the archive index or regenerate on a schedule.
- Avoid heavy transformations on every request; cache the parsed frontmatter if your content set is large.
Next steps
- Add tests around the archive grouping helper to lock in ordering and date parsing behavior.
- Instrument the archive page with basic analytics to see how readers navigate older content.

