710 字
4 分钟
Astro + Fuwari + GitHub + Vercel + Cloudflare 博客部署教程

Astro + Fuwari + GitHub + Vercel + Cloudflare 博客部署教程#

架构说明#

本地 Fuwari → GitHub 仓库 → Vercel 自动构建 → Cloudflare DNS → 用户访问

一、环境准备#

需要安装#

需要的账号#


二、本地搭建#

1. 下载 Fuwari 模板#

https://github.com/saicaca/fuwari 下载 ZIP 解压到 D:\Blog

或用 git clone:

Terminal window
git clone https://github.com/saicaca/fuwari D:\Blog

2. 安装依赖#

Terminal window
cd /d D:\Blog
pnpm install
pnpm add sharp

3. 本地预览#

Terminal window
pnpm dev

访问 http://localhost:4321 查看效果


三、配置博客#

修改 src/config.ts#

export const siteConfig: SiteConfig = {
title: "博客标题",
subtitle: "副标题",
lang: "zh_CN",
// ...
};
export const profileConfig: ProfileConfig = {
avatar: "assets/images/demo-avatar.png",
name: "你的名字",
bio: "个人简介",
links: [],
};
export const licenseConfig: LicenseConfig = {
enable: false, // 关闭许可协议显示
name: "",
url: "",
};

四、写文章#

文章位置#

src/content/posts/ 目录下,.md 格式

文章格式(frontmatter 必须)#

---
title: 文章标题
published: 2025-12-30
tags: []
---
正文内容,支持 Markdown 语法...

必填字段#

  • title: 文章标题
  • published: 发布日期(YYYY-MM-DD 格式)
  • tags: 标签数组(可以为空 []

可选字段#

  • description: 文章描述
  • category: 分类
  • image: 封面图
  • draft: true: 草稿(不会显示)

五、推送到 GitHub#

首次推送#

  1. 在 GitHub 创建新仓库(不勾选 README)

  2. 执行命令:

Terminal window
cd /d D:\Blog
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/你的用户名/仓库名.git
git branch -M main
git push -u origin main

六、Vercel 部署#

  1. 登录 Vercel(用 GitHub 账号)
  2. 点击 Add NewProject
  3. 导入 GitHub 仓库
  4. Framework Preset 选择 Astro
  5. 点击 Deploy

部署完成后会得到 xxx.vercel.app 域名


七、Cloudflare DNS 配置#

Vercel 添加自定义域名#

项目 → Settings → Domains → 输入域名 → Add

Cloudflare 添加 DNS 记录#

类型名称内容代理状态
CNAMEblogcname.vercel-dns.comDNS only(灰云)

如果开橙云代理#

Cloudflare → SSL/TLS → 加密模式改为 Full


八、常用命令#

本地开发#

Terminal window
cd /d D:\Blog
# 启动本地预览
pnpm dev
# 停止预览
Ctrl + C

更新推送#

Terminal window
# 添加所有更改
git add .
# 提交(引号里写本次改动说明)
git commit -m "更新说明"
# 推送到 GitHub(Vercel 自动部署)
git push

一键推送(三条合一)#

Terminal window
git add . && git commit -m "更新" && git push

清除本地 DNS 缓存(访问不了时试试)#

Terminal window
ipconfig /flushdns

九、日常更新流程#

  1. src/content/posts/ 新建 .md 文件
  2. 写好 frontmatter 和正文
  3. pnpm dev 本地预览
  4. 满意后推送:
Terminal window
git add .
git commit -m "新文章:xxx"
git push
  1. 等 1-2 分钟 Vercel 自动部署完成

常见问题#

Q: 文章不显示#

检查 frontmatter 是否完整,titlepublishedtags 必须有

Q: 构建失败#

查看 Vercel → Deployments → Build Logs 错误信息

Q: 自定义域名访问不了#

  1. 检查 DNS 记录是否正确
  2. 清除浏览器缓存或用无痕模式
  3. 执行 ipconfig /flushdns

Q: 部署到错误分支#

Vercel → Settings → Git → Production Branch 改为 main