分享一些本站的搭建方式,本站采用 HEXO + Cloudflare Pages 的纯静态网页方式进行搭建与部署。

一、工具准备

1.git
官网:https://git-scm.com/
2.node.js(LTS版)
官网:https://nodejs.org/
3.代码编辑器 推荐VS Code
官网:https://code.visualstudio.com/
4.GitHub账号
GitHub官网:https://github.com/

二、本地搭建HEXO博客

1.安装hexo
(1)打开终端下载hexo:

npm install -g hexo-cli

(2)验证hexo:

hexo -v

2.创建文件夹并初始化
(1)创建博客目录

hexo init myblog

(2)进入目录

cd myblog

(3)安装依赖

npm install

(4)本地预览博客

hexo s

三、安装博客主题

1.安装主题到themes文件夹(以本主题为例)

cd themes
git clone https://github.com/fly6022/hexo-theme-kuri.git themes/kuri

2.修改全局配置切换主题
(1)在myblog/_config.yml中找到theme

theme: kuri

(2)重启本地服务生效

hexo s

四、基础设置修改

修改全局变量_config.yml,根据自己的喜好修改博客基础信息、页面样式、导航等内容。

五、新建第一篇文章

hexo new "第一篇博客文章"

文件会自动生成:source/_posts/第一篇博客文章.md
写完后本地预览:

hexo clean && hexo s

六、推送源码到GitHub

  1. 在 GitHub 创建一个公开仓库,不要勾选 Initialize this repository with a README
  2. 博客根目录执行初始化与推送
git init
git add .
git commit -m "init hexo blog"
git remote add origin 你的仓库git地址
git push -u origin main

七、Cloudflare Pages 自动部署

  1. 进入 Cloudflare Pages 控制台,点击 Create a project
  2. 连接你的 GitHub 账号,选中存放 Hexo 源码的仓库
  3. 构建配置填写:
  • Framework preset:Hexo
  • Build command:hexo clean && hexo generate
  • Build output directory:public
  1. 保存并部署,等待首次构建完成。

八、可选拓展

  1. Waline 评论系统
    独立部署 Waline(Vercel + Neon PostgreSQL),在 _config.kuri.yml 填入你的 Waline 服务地址开启评论。

  2. 绑定自定义域名
    在 Cloudflare Pages 项目设置 → Custom domains,添加域名,并在域名 DNS 面板解析至 Cloudflare。

  3. 日常更新文章流程

hexo new "文章标题"
# 编辑md文件内容
hexo clean && hexo s #本地预览无误
git add .
git commit -m "新增:xxx文章"
git push
# 推送后等待Cloudflare自动部署