Renaming src/posts/ to src/pages/
By Claude Sonnet 4.5 · January 17, 2026
docs
Comprehensive analysis of all code changes required to rename the content directory from src/posts/ to src/pages/
The directory
Change 1 - Line 7 (getAllPosts function):
Change 2 - Line 16 (dynamic import):
Change 3 - Line 30 (getAllDocs function):
Change 4 - Line 39 (dynamic import):
This is a straightforward refactor with:
src/posts/ currently contains all content files (both posts and docs), which creates semantic confusion. This document outlines all code changes required to rename it to src/pages/.Why This Change?
The term "posts" implies blog posts, but the directory actually contains:- Blog posts (type: 'post')
- Documentation (type: 'doc')
- Commit documentation (type: 'doc:commit')
src/pages/ better represents that this directory contains all content pages, regardless of type. This also aligns with the fact that we filter by the type metadata field, not by directory location.Impact Analysis
Critical Code Changes (5 locations)
These are the actual code files that reference the directory and must be updated:1. src/lib/posts.ts (4 changes)
File:src/lib/posts.tsChange 1 - Line 7 (getAllPosts function):
const postsDirectory = path.join(process.cwd(), 'src/posts');→ const postsDirectory = path.join(process.cwd(), 'src/pages');Change 2 - Line 16 (dynamic import):
const module = await import(`@/posts/${filename.replace('.tsx', '')}`);→ const module = await import(`@/pages/${filename.replace('.tsx', '')}`);Change 3 - Line 30 (getAllDocs function):
const postsDirectory = path.join(process.cwd(), 'src/posts');→ const postsDirectory = path.join(process.cwd(), 'src/pages');Change 4 - Line 39 (dynamic import):
const module = await import(`@/posts/${filename.replace('.tsx', '')}`);→ const module = await import(`@/pages/${filename.replace('.tsx', '')}`);2. src/app/posts/[slug]/page.tsx (1 change)
File:src/app/posts/[slug]/page.tsxLine 32 (dynamic import):const postModule = await import(`@/posts/${filename}`);→ const postModule = await import(`@/pages/${filename}`);3. src/app/docs/[slug]/page.tsx (1 change)
File:src/app/docs/[slug]/page.tsxLine 32 (dynamic import):const docModule = await import(`@/posts/${filename}`);→ const docModule = await import(`@/pages/${filename}`);4. tsconfig.json - Path Alias (Optional)
File:tsconfig.jsonCurrently, the path alias @/* maps to ./src/*, which means @/posts/automatically resolves to ./src/posts/. When we rename the directory to src/pages/, the imports @/pages/ will automatically work.No change required - the existing @/* alias will handle it.Documentation Updates
These content files contain references tosrc/posts/ in their prose/documentation. They should be updated for accuracy but won't break functionality if missed:src/posts/site-summary.tsx- 2 mentions in explanatory textsrc/posts/docs-routing.tsx- 6 mentions in documentation and code examplessrc/posts/commit-content-system-refactor.tsx- 5 file path references in lists.github/copilot-instructions.md- Directory structure mention
URL Routes Unaffected
The URL structure (/posts/[slug] and /docs/[slug]) is determined by the directory structure in src/app/, not by the content directory name. Renamingsrc/posts/ to src/pages/ will not affect URLs.Implementation Steps
Recommended order of operations:- 1. Update the 5 critical code files first (src/lib/posts.ts, both route handlers)
- 2. Rename the directory:
mv src/posts src/pages - 3. Test the application to ensure all routes work
- 4. Update documentation files at leisure (cosmetic only)
- 5. Commit the changes
Risk Assessment
Risk Level: LowThis is a straightforward refactor with:
- Only 5 critical code changes needed
- No TypeScript interface changes
- No URL structure changes
- Easy to test (if routes work, the change is successful)
- Easy to rollback if needed (just rename the directory back)
Summary
Renamingsrc/posts/ to src/pages/ requires updating 5 critical import/path references in 3 files. All other mentions are documentation only. The change eliminates semantic confusion and better represents the directory's purpose as a container for all content types.