github静态部署hexo+fluid并使用CF自定义域名

github静态部署hexo+fluid并使用CF自定义域名

一、本地搭建 Hexo + Fluid

1. 安装环境

1
npm install -g hexo-cli

初始化项目:

1
2
3
hexo init blog
cd blog
npm install

2. 安装 Fluid 主题

1
npm install --save hexo-theme-fluid

修改 _config.yml:

1
theme: fluid

(Fluid 官方推荐 Hexo 5+)

3. 本地预览

1
hexo s

浏览器访问:

1
http://localhost:4000

二、推送到 GitHub

1. 创建仓库

hexo-blog

2. 推送代码

1
2
3
4
5
6
git init
git add .
git commit -m "init"
git branch -M main
git remote add origin https://github.com/你的用户名/仓库名.git
git push -u origin main

三、Cloudflare Pages 部署

1. 创建 Pages 项目

进入 Cloudflare:
(注意!这一步要选择page不要选择worker)

1
Workers & Pages → Create → Pages → Connect to Git

选择你的 GitHub 仓库

2. 构建配置(关键)

填写:

1
2
3
Framework preset: None
Build command: npm install && npx hexo generate
Build output directory: public

说明:

1
2
hexo generate 会生成静态文件到 public/
Cloudflare 会自动部署该目录

3. 自动部署

之后每次:

1
git push

Cloudflare 会自动重新构建并上线

四、绑定 Cloudflare 域名

1. 添加域名

1
Cloudflare Pages → Settings → Custom domains

输入你的域名,例如:

1
blog.example.com

2. DNS 自动配置

Cloudflare 会自动创建:

1
CNAME blog → xxx.pages.dev

所有步骤已完成,可以访问博客页面了!


github静态部署hexo+fluid并使用CF自定义域名
https://hexo.wildew.org/2026/04/23/hexobuild/
作者
Wildew
发布于
2026年4月23日
许可协议