Next.jsReact博客启动器

nextjs-blog-tw-starter — Next.js 博客模板

作者 jbrace817

这是一个基于 Next.js 14、Tailwind CSS、Contentlayer 和 Decap CMS 的开源博客起始模板,支持 MDX 写作、多分类内容管理和明暗主题切换。

看看你的网站会是什么样

浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。

3 个预览视图
桌面端首页1 / 3
桌面端截图首屏预览

由服务器浏览器实际访问页面后截取。

全部页面与视图 3

截图用于了解视觉与布局,交互效果请以实际项目为准。

采集于 2026-10-14查看来源

值得关注的模板亮点

从已有项目资料中,快速了解它的特点。

01

使用 Next.js 14 与 Tailwind CSS 构建

02

支持 MDX 格式写作,并通过 Contentlayer 管理内容与生成 TypeScript 类型

03

内置 Decap CMS 管理界面,可本地运行或部署后使用

04

预设 blog、inspiration、podcasts、resources、tools 等内容分类

05

提供 ExportedImage 组件用于静态导出时的图片优化

06

自动适配系统深色/浅色模式

模板详细介绍

该模板由 design-code.tips 提供,用于搭建现代博客。技术栈包括 Next.js 14、Tailwind CSS、MDX、Contentlayer 和 Decap CMS。内容以 MDX 文件形式存放在 content/ 目录下的 blog、inspiration、podcasts、resources、tools 等分类文件夹中,通过 Contentlayer 管理并自动生成 TypeScript 类型。模板支持 frontmatter 字段如 title、description、date、featured、tags 等,并内置了针对静态导出的图片优化组件 ExportedImage。Decap CMS 提供图形化管理界面,本地使用时需单独运行 npx decap-server,部署到 Netlify 时可结合 Netlify Identity 和 Git Gateway 实现登录与内容提交。README 未说明该模板的生产就绪程度、性能表现或具体框架版本号。

Next.js博客启动器

适合你的项目吗?

适用场景

  • 搭建个人技术博客或设计灵感分享站点
  • 需要图形化 CMS 管理 MDX 内容的静态博客项目
  • 使用 Next.js 和 Tailwind CSS 快速启动内容型网站
  • 希望利用 Contentlayer 获得内容类型安全的开发场景

适合人群

  • 熟悉 Next.js 和 Tailwind CSS 的前端开发者
  • 需要以 MDX 写作并希望有 CMS 辅助的内容创作者
  • 计划部署到 Netlify 或 Vercel 的静态博客项目

上手与定制指南

结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。

  1. 1

    克隆仓库后运行 npm install 安装依赖,再执行 npm run dev 启动开发服务器。

  2. 2

    使用 Decap CMS 时需在另一个终端运行 npx decap-server,并访问 http://localhost:3000/admin/index.html。

  3. 3

    本地测试 CMS 需在 public/admin/config.yml 中设置 local_backend: true 并重启服务。

  4. 4

    部署到 Netlify 并启用 Decap CMS 时,需开启 Netlify Identity 和 Git Gateway,并邀请用户登录 /admin。

  5. 5

    若部署时遇到 sharp 相关错误,可尝试删除 package-lock.json 文件。

查看仓库使用说明

授权与来源资料

使用条件与限制

免费使用 · 保留许可声明

本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。

使用时需要遵守

  • 允许免费使用、修改、商用和分发该版本代码。
  • 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
  • 代码按现状提供;担保与责任限制以原许可证及适用法律为准。

额外费用与待核对事项

  • 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
  • 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
  • 使用 Decap CMS 时需要在另一个终端单独运行 npx decap-server 服务,并访问 http://localhost:3000/admin/index.html 才能使用图形化管理界面。
  • 本地测试 CMS 需在 public/admin/config.yml 中设置 local_backend: true,且修改后必须重启服务器。
  • 若部署到 Netlify 并使用 Decap CMS,必须启用 Netlify Identity 才能让用户登录 /admin 管理面板。
  • 需在 Netlify Identity 设置中启用 Git Gateway,CMS 才能通过 OAuth 认证与仓库交互。
  • 需要邀请自己或团队成员(通过邮件邀请)才能获得 CMS 登录权限。
  • 部署时若遇到 sharp 相关错误,可能需要删除 package-lock.json 文件来解决依赖问题。
查看原文依据

Permission is hereby granted, free of charge

许可证原文

To use [Decap CMS](https://decapcms.org/), you'll need to run its server alongside your Next.js development server. This can be done by running the following command **in a separate terminal**:

README 原文

> If you'd like to test the CMS locally, set `local_backend: true` in `public/admin/config.yml`. Don't forget to restart the server after making changes.

README 原文

If you're deploying your site with Netlify and using Decap CMS for content management, you'll need to enable [Netlify Identity](https://docs.netlify.com/security/secure-access-to-sites/identity/) to allow users to log in to the CMS at /admin.

README 原文

- In the Identity settings, enable Git Gateway. This will allow your CMS to interact with the repository via OAuth authentication.

README 原文

- Invite yourself or other team members to the CMS. Go to the "Identity" tab, click Invite Users, and send invites via email.

README 原文

> If you encounter errors related to **`sharp`** during deployment, please try removing the `package-lock.json` file, as this can sometimes resolve issues with Sharp's dependencies.

README 原文
https://github.com/jbrace817/nextjs-blog-tw-starter/blob/main/LICENSEhttps://github.com/jbrace817/nextjs-blog-tw-starter/blob/main/README.md

DeepSeek 根据仓库许可证和 README 整理 ·2026-10-14。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。

项目核对记录与介绍依据

模板资料

来源平台
GitHub
资料与维护参考分
资料较完整 · 79 / 100
技术栈
Next.js · React
网站类型
博客 · 启动器
这个分数如何计算

本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。

这个项目需要核对什么

记录的仓库更新时间
2025-03-08
截图检查日期
2026-10-14

已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。

目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。

查看具体选型方法 →

介绍的制作与核对状态

介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。

审核声明: codex-user-requested-batch-review-20261017 · 2026-10-16

查看当时使用的来源资料

SHA-256: 154c27f60457f1666aa83c958d4c8e228d0f256e393d46d114e68fd74af4f99e

2026-10-14T08:36:46.589Z

来源文件 / 仓库
# 🚀 Next.js 14 Blog Starter with Tailwind CSS, Contentlayer, & Decap CMS

[![Netlify Status](https://api.netlify.com/api/v1/badges/51784f6e-1f73-4db9-ad5e-c0c514a47181/deploy-status)](https://app.netlify.com/sites/nextjs-blog-tailwind-starter/deploys)

Welcome to the [**design-code.tips**](https://design-code.tips/) Next.js starter! 

This open-source starter template is built with **Next.js 14**, **Tailwind CSS**, **Contentlayer**, and **Decap CMS**. It's designed to be a simple and customizable way to launch a modern blog, with support for MDX and multiple categories like Code Blog, Inspiration, Podcasts, Tools, and Resources.

![Starter Cover Preview](/starter-cover.png)

[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/ositaka/nextjs-blog-tailwind-starter/)
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/import/project?template=https://github.com/ositaka/nextjs-blog-tailwind-starter/)

---

## 💻 Starter Preview

![Homepage in light and dark modes](/starter-preview.png)

## ✨ Features

- 🛠️ **Next.js 14**: Fast, modern React framework for production-ready web applications.
- 🎨 **Tailwind CSS**: Utility-first CSS for rapid UI development.
- 📄 **MDX Support**: Write your blog posts in Markdown with JSX components.
- 🗂️ **Contentlayer**: Simple content management with files as data.
- 📋 **Decap CMS**: Easily manage your posts through a friendly CMS interface.
- 🏷️ **Categories**: Pre-configured sections for Code Blog, Inspiration, Podcasts, and Tools.
- 🖼️ **Optimized Images**: Use the `<ExportedImage />` component from the [`next-image-export-optimizer`](https://www.npmjs.com/package/next-image-export-optimizer) package for optimized image handling in static exports, replacing the default Next.js `<Image />` component for better control over image quality, formats (like WEBP), and cache settings.
- 🌗 **Dark/Light Mode**: Automatically adapts to the user's operating system settings.

## 📦 Tech Stack

- **Next.js 14**
- **Tailwind CSS**
- **MDX**
- **Contentlayer**
- **Decap CMS**

## 🚀 Quick Start

Follow these steps to get the project up and running:

1. **Clone the repository**:

   ```bash
   git clone https://github.com/ositaka/nextjs-blog-tailwind-starter
   cd nextjs-blog-tailwind-starter
   ```

2. **Install dependencies:**

   ```bash
   npm install
   ```

3. **Run the development server:**

   ```bash
   npm run dev
   ```

   Open http://localhost:3000 in your browser to see the app running.

---

## ✍️ Writing Content (without CMS)

You can create different types of content (like blog posts or podcasts) in separate folders under `content/`. Each folder corresponds to a category in your blog.

Content is written in **MDX** format and managed using [**Contentlayer**](https://contentlayer.dev/). To create a new post, add an `.mdx` file in the appropriate folder inside `content/` for each category:

```
content/
  ├── blog/
  ├── inspiration/
  ├── podcasts/
  ├── resources/
  └── tools/
```

Each post supports frontmatter fields like `title`, `description`, `date`, and `featured`.

Example frontmatter for a blog post:

```md
---
templateKey: blog
title: >
  Custom Scrollbar with CSS (WebKit)
date: 2021-06-19T19:28:37.629Z
featured: true
description: >
  Learn how to customize the scrollbar with CSS for WebKit browsers, providing a visually appealing design for scrollable elements on your website.
tags:
  - web-development
  - css
---

Your markdown content here...
```

Example inspiration post, with a video:

```md
---
templateKey: inspiration
title: >
  2Advanced Studios — Flash website in 2003
date: 2003-03-03T15:04:10.000Z
featured: true
description: >
  An old flash website (v4) of 2advanced.com, that has inspired me quite a lot in my teenage years.
tags:
  - animation
  - flash
  - website
image: /media/2advanced-flash-website-v4-2003.jpg
---

<Video src="/media/2advanced-flash-website-v4-2003.mp4" />

## © 2003 Advanced Studios

Currently, the 2Advanced Studios are closed for real, since some years already.
```

## 🖥️ Decap CMS

### Run the CMS server

To use [Decap CMS](https://decapcms.org/), you'll need to run its server alongside your Next.js development server. This can be done by running the following command **in a separate terminal**:

```bash
npx decap-server
```

You can then access the CMS at http://localhost:3000/admin/index.html.

> [!NOTE]  
> If you'd like to test the CMS locally, set `local_backend: true` in `public/admin/config.yml`. Don't forget to restart the server after making changes.

> [!TIP]  
> For more information, refer to the [Decap CMS documentation](https://decapcms.org/docs/). If you'd like to see an advanced example of how to use Decap CMS, check out this [Decap CMS `config.yml` example](https://github.com/decaporg/decap-cms/blob/main/dev-test/config.yml).

### Screenshots

![Decap CMS - Screenshot](/screenshot--cms1.png)
![Decap CMS - Screenshot](/screenshot--cms2.png)

---

## 📖 Configuration

Customize the project to suit your needs by editing the following files:

- [`config.js`](https://github.com/ositaka/nextjs-blog-tailwind-starter/blob/main/config.js): Your Bleg Starter configuration.
- [`tailwind.config.js`](https://github.com/ositaka/nextjs-blog-tailwind-starter/blob/main/tailwind.config.js): Tailwind CSS configuration.
- [`next.config.js`](https://github.com/ositaka/nextjs-blog-tailwind-starter/blob/main/next.config.js): Next.js custom settings.
- [`next-seo.config.js`](https://github.com/ositaka/nextjs-blog-tailwind-starter/blob/main/next-seo.config.js): SEO configuration for Next.js.
- [`contentlayer.config.js`](https://github.com/ositaka/nextjs-blog-tailwind-starter/blob/main/contentlayer.config.ts): Contentlayer configuration for MDX files.
- [`public/admin/config.yml`](https://github.com/ositaka/nextjs-blog-tailwind-starter/blob/main/public/admin/config.yml): Decap CMS configuration.

### `next.config.js`:

- The project uses the [**`next-image-export-optimizer`**](https://www.npmjs.com/package/next-image-export-optimizer) package to enhance image handling in static exports.
- Custom settings for image optimization:
  - **Image Folder**: Images are stored in the `public/media` folder.
  - **Export Settings**: Optimized images are exported to the `out/` folder.
  - **Quality**: Image quality is set to **75%**.
  - **WEBP Format**: By default, the images are converted to **WEBP** for improved performance.
  - **Blurred Placeholder**: Blurry placeholders are enabled for a smoother loading experience. To disable this, set `nextImageExportOptimizer_generateAndUseBlurImages` to `false` in your `.next.config.js` file, and pass `placeholder="empty"` to all `<ExportedImage>` components.

> [!NOTE]  
> Replace Next.js `<Image />` components with `<ExportedImage />` to leverage these optimizations.

Example usage:

```tsx
import ExportedImage from 'next-image-export-optimizer'

<ExportedImage
  src="/media/example.jpg"
  alt="Example Image"
  width={800}
  height={600}
  placeholder="blur"
/>
```

### TypeScript and Contentlayer Integration

This project uses [**Contentlayer**](https://contentlayer.dev/) to [automatically generate TypeScript types for your content](https://contentlayer.dev/docs/concepts/type-safety). The configuration is managed in the `contentlayer.config.ts` file located at the root of the project. Each document type (e.g., Blog, Inspiration, Podcasts, Tools, Pages) has its own structure and generated types, ensuring type safety when working with content in your components.

Below is an example of the TypeScript types generated for the **Blog** document:

```ts
import { defineDocumentType, makeSource } from 'contentlayer2/source-files'

const Blog = defineDocumentType(() => ({
  name: 'Blog',
  filePathPattern: `blog/*.md`,
  contentType: 'markdown',
  fields: {
    title: { type: 'string', required: true },
    date: { type: 'date', required: false },
    description: { type: 'string', required: false },
    tags: { type: 'json', required: false },
    templateKey: { type: 'string', required: true },
    featured: { type: 'boolean', required: false },
  },
  computedFields: {
    slug: {
      type: 'string',
      resolve: (doc) => doc._raw.sourceFileName.replace(/\.md/, ''),
    },
  },
}))

export default makeSource({
  contentDirPath: 'content',
  documentTypes: [Page, Blog, Inspiration, Podcasts, Tools, Resources],
  disableImportAliasWarning: true,
})
```

> [!NOTE]  
> The `slug` field is automatically computed from the filename, removing the `.md` extension.

#### Where to Find the Generated Types

The types are generated into the `./.contentlayer` directory and can be used throughout the application. Simply import the types from there:

```tsx
import { allBlogs, Blog } from '../../.contentlayer/generated')
import { pick } from '@contentlayer2/client'
```

#### Working with Content in Components

When working with content in your components, you can use the generated types to ensure type safety. For example, when mapping over blog posts:

```tsx
let blogs = allBlogs.map((blog) => pick(blog, ['title', 'date', 'slug', 'description', 'templateKey'])
```

In this example, `allBlogs` is an array of `Blog` types, and we're using the `pick` function to select specific fields from each blog post.

#### Type Assertion

When working with content from `allBlogs`, you can assert the type to ensure it's a `Blog` type:

```tsx
const blog = allBlogs.find((b) => b.slug === params.slug) as Blog
```

This way, you can access the fields of the `Blog` type without any issues.

#### Passing Content to Components

When passing content to components, you can use the `Blog` type to ensure the correct structure:

```tsx
<BlogPostCard key={post.slug} post={post as Blog} />
```

With these types in place, you can benefit from strong typing and auto-completion when working with your content.

---

## 🚀 Deploy

Deploy your own instance of this blog starter project using one of the following providers:

[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/ositaka/nextjs-blog-tailwind-starter/)
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/import/project?template=https://github.com/ositaka/nextjs-blog-tailwind-starter/)

> [!NOTE]  
> If you encounter errors related to **`sharp`** during deployment, please try removing the `package-lock.json` file, as this can sometimes resolve issues with Sharp's dependencies.

### Setting up Netlify Identity with Decap CMS

If you're deploying your site with Netlify and using Decap CMS for content management, you'll need to enable [Netlify Identity](https://docs.netlify.com/security/secure-access-to-sites/identity/) to allow users to log in to the CMS at /admin.

1. **Enable Identity**:

   - Go to your site's dashboard on [Netlify](https://www.netlify.com/), navigate to the "Identity" tab, and click Enable Identity.

2. **Configure Git Gateway**:

   - In the Identity settings, enable Git Gateway. This will allow your CMS to interact with the repository via OAuth authentication.

3. **Invite Users**:

   - Invite yourself or other team members to the CMS. Go to the "Identity" tab, click Invite Users, and send invites via email.

4. **Login Access**:

   - Once enabled, users can log in to the /admin panel using their Netlify Identity credentials.

Here's a preview of how this might look in your `config.yml` for Decap CMS:

```yaml
backend:
  name: git-gateway
  branch: main
```

To enable Netlify Identity in this starter project, the following component is used in the `layout.tsx` file:

```tsx
<NetlifyIdentityRedirect />
```

This component automatically redirects users to the login page if they are not authenticated.

> [!TIP]  
> For more information on setting up Netlify Identity with Decap CMS, visit the [Decap CMS documentation – Choosing a Backend](https://decapcms.org/docs/choosing-a-backend).

---

## 📄 License

This project is licensed under the MIT License. See the [LICENSE](/LICENSE) file for details.

---

## 📣 Contributing

Contributions are welcome! Here are some ways you can help improve the project:

- **Bug Fixes**: If you encounter any issues, please submit an issue or pull request to address it.
- **Feature Additions**: Have an idea for a new feature? Open an issue to discuss it or submit a pull request with your implementation.
- **Documentation Improvements**: Help us enhance the README by suggesting edits or additional information.

### How to Contribute

1. Fork the repository
2. Create a new branch (`git checkout -b feature/your-feature-name`)
3. Make your changes
4. Push to your branch (`git push origin feature/your-feature-name`)
5. Create a pull request

Thank you for considering contributing to the project!

## 🔗 Links

- [Demo](https://nextjs-blog-tailwind-starter.netlify.app/)
- [Documentation](https://github.com/ositaka/nextjs-blog-tailwind-starter/blob/main/README.md)
- [GitHub Repo](https://github.com/ositaka/nextjs-blog-tailwind-starter)

---

## 🙌 Acknowledgments

Built with ❤️ in 🇵🇹 and 🇧🇪 using [Next.js](https://nextjs.org/) (an amazing open-source React framework), [Tailwind CSS](https://tailwindcss.com/) (for rapid UI development), [Contentlayer](https://contentlayer.dev/) (for managing content), and [Decap CMS](https://decapcms.org/) (for a user-friendly content management experience).

A big thank you to the communities behind these projects for their hard work and dedication!
反馈内容错误

看看同类模板

对比同技术栈与用途的模板,找到更适合的视觉与内容结构。