Next.js Project Structure
A good project structure keeps a website clean and easy to manage.
For a blog built with Next.js, files can be organized like this:
Project Structure
project/
│
├── app/
│ ├── articles/
│ │ └── [...slug]/
│ │ └── page.tsx
│ │
│ ├── archive/
│ │ └── page.tsx
│ │
│ ├── login/
│ │ └── page.tsx
│ │
│ ├── subscribe/
│ │ └── page.tsx
│ │
│ ├── layout.tsx
│ ├── page.tsx
│ └── globals.css
│
├── components/
│ ├── main/
│ │ ├── MainHeader.tsx
│ │ ├── MainFooter.tsx
│ │ └── ShareButton.tsx
│ │
│ ├── blog/
│ │ ├── ArticleCard.tsx
│ │ ├── ArticleList.tsx
│ │ └── TableOfContents.tsx
│ │
│ ├── comments/
│ │ ├── CommentSection.tsx
│ │ ├── CommentForm.tsx
│ │ └── CommentList.tsx
│ │
│ ├── auth/
│ │ ├── LoginForm.tsx
│ │ └── LogoutButton.tsx
│ │
│ ├── subscribe/
│ │ └── SubscribeForm.tsx
│ │
│ └── archive/
│ └── ArchiveList.tsx
│
├── content/
│ └── posts/
│ ├── article-one.md
│ ├── article-two.md
│ └── article-three.md
│
├── lib/
│ ├── posts.ts
│ ├── auth.ts
│ ├── comments.ts
│ └── subscribe.ts
│
├── public/
│ ├── favicon.png
│ └── images/
│ └── blog/
│
├── package.json
├── next.config.ts
├── tsconfig.json
└── README.md
