两年之前就搭建好了这个博客,但是一直没更新,最近又想更新一下,就想记录一下博客搭建的过程以及发布新博客的步骤,做一个备忘。

我的博客使用的主题是stellar.

博客初始化

搭建博客

  1. 安装hexo: npm install hexo-cli -g
  2. 创建博客: hexo init blog
  3. 进入博客文件夹: npm i hexo-theme-stellar
  4. 在 blog/_config.yml 文件中找到并修改: theme: stellar

部署博客

  1. 创建一个 github 仓库,将生成的静态文件push到gh-pages分支
  2. 在Cloudflare中 Workders&Pages创建一个Application, 关联到github仓库
  3. 配置应用时,deploy命令为: npx wrangler deploy --assets=./ --compatibility-date 2026-01-31

添加新博客

创建新博客文件: hexo new [layout] <title>, 其中layout是可选的
预览新博客: hexo s
动态刷新预览: hexo clean && hexo s -w
生成静态文件: hexo g
发布新博客: hexo d

更新日志

2026-05-15

新加博客后,需要通过将文件添加到git仓库,并push到远程分支,这个过程还挺麻烦,就搞了个脚本,运行之后自动提交并push

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env bash
# Stage changes under source/, commit with timestamp message, push.
set -euo pipefail
cd "$(dirname "$0")/.."

git add -- source/

if git diff --cached --quiet; then
echo "Nothing to commit under source/"
exit 0
fi

git commit -m "$(date '+%Y-%m-%d %H:%M:%S')"
git push