Hexo 个人博客配置记录(GitHub Pages + Butterfly 主题 + Waline 评论 + 自动部署)
备份备份,收藏栏都块满了,减轻减轻收藏夹压力
原博客链接:https://gannia.top/tokepson.github.io/
由于原先的网页是纯静态的,且写起来很麻烦
因此转移到了Hexo平台
https://gannia.top/
个人博客展示:欢迎各位访问以及友联
(写博文好麻烦不想写了…)
需要注意的是,本博客是部署在github上的因此访问可能有异常(虽然有阿里云服务器可以Nginx “转发”但暂时懒得搞),同时评论服务国内用户也无法直接使用(要不还是搭个吧...好麻烦)
一、项目初始化流程
1. 安装 Hexo(首次)
npm install -g hexo-cli
2. 创建博客项目目录
hexo init hexo-blog
cd hexo-blog
npm install
3. 本地运行预览
hexo s
浏览器打开:http://localhost:4000
二、配置主题(Butterfly)
1. 下载 Butterfly
git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly
2. 修改配置文件 _config.yml
theme: butterfly
3. 安装依赖插件(如有)
npm install hexo-generator-searchdb --save
三、配置 Git 部署
1. _config.yml
中增加部署设置
deploy:
type: git
repo: https://github.com/你的用户名/你的仓库.git
branch: main
2. 安装部署插件
npm install hexo-deployer-git --save
四、文章写作与发布
1. 创建文章
hexo new post "文章标题"
- 创建文件夹
hexo new post 文件夹名称
然后编辑 source/_posts/文章标题.md
文件。
博文内容以md格式写在文件内部
2. 设置分类与标签
---
title: 我的文章
date: 2025-06-17 00:00:00
categories:
- 技术
- Hexo
tags:
- Butterfly 主题
- Hexo
---
3. 生成并部署
hexo clean
hexo g -d
五、评论系统配置(Waline)
1. 部署 Waline 服务(使用 Vercel)
注 同时还需要去leancloud注册账号并获取Api值(建议国际版,国内版还需要申请域名)
详细可以看这里 Waline, LearnCloud配置教程, Vercel
- 克隆:https://github.com/walinejs/waline
- 在github里创建你自己的waline仓库,并部署至 Vercel
- 设置环境变量(如
LEAN\_ID
,LEAN\_KEY
,LEAN\_KEY
等)这边需要注意下 必须要设置
2. 修改 Butterfly 主题配置 _config.butterfly.yml
comment:
type: Waline
serverURL: https://你的-waline.vercel.app
pageview: true
配置教程链接:
Hexo博客搭建基础教程(三)
、Butterfly主题的基础配置
3. 若报错 Not initialized
或 404
- 确保你设置好 LeanCloud 的应用
- Waline 后台功能需要 admin 密钥或配置 LC 应用权限
六、自动部署(可选)
1. 使用 GitHub Actions 自动部署 Hexo 到 GitHub Pages
- 创建
.github/workflows/deploy.yml
- 示例配置可见:https://github.com/marketplace/actions/deploy-hexo-blog-to-github-pages
七、可视化管理(可选)
1. 使用 hexo-admin
npm install hexo-admin --save
运行:
hexo s
然后打开 http://localhost:4000/admin
使用后台管理界面。
八、常用命令小结
命令 | 功能 |
---|---|
hexo new post "标题" |
新建文章 |
hexo new post 文件名 |
新建文件夹 |
hexo g |
生成静态文件 |
hexo s |
本地启动服务预览 |
hexo d |
部署到远程仓库 |
hexo g -d |
好像也是部署到远程仓库(我用的) |
hexo clean |
清除缓存和旧文件 |
九、参考配置工具
- 本地写作:VSCode + Markdown 插件
- 实时预览:hexo s
- 自动化:GitHub Actions
- 评论:Waline
- 搜索:hexo-generator-searchdb
- 主题优化:Butterfly + 自定义配置
如需进一步可视化创作、Web 后台文章管理,可结合 Netlify CMS 或搭建更完整的 CMS 前端。
献丑了: