hexo结合博客和简历

介绍

在hexo themes 里看到有简历的模版,于是想把它和主站博客整合到一起的想法。

有一个私人项目:blog ,一个公共项目 username.github.io, 现在使用 hexo 写源码放到 blog 中,通过github action 创建静态网站,并设置到 公共项目 username.github.io 分支 gh-pages 作为 pages. 现在我想 再创建一个 resume的私人项目,也是一个 Hexo 网站,写到 username.github.io 分支 gh-pages 的 /resume 下。

思路一句话:
“resume 仓库自己 hexo g → 把产物 public/* 推到 blog 仓库的 resume-dist 分支(空分支即可) → blog 主 Action 在生成完主站后,再把 resume-dist 分支里的文件整个 拷到 public/resume/ → 最后统一 pushusername.github.iogh-pages。”

这样做的好处:

  • resume 源码完全私有;
  • 主站 Action 只拉产物,不拉源码;
  • username.github.io 来说只是多了一个 /resume 目录,毫无感知。

一、给 resume 仓库配极简 Action

文件:.github/workflows/build.yml(放在 resume 仓库)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
name: Build Resume Hexo

on:
push:
branches: [ main ]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
- run: npm ci
- run: npx hexo generate

# 把产物推到 blog 仓库的 resume-dist 分支
- name: Deploy to blog/resume-dist
uses: peaceiris/actions-gh-pages@v4
with:
personal_token: ${{ secrets.PAT }} # 需有 repo 权限
external_repository: yourname/blog # 你的私人 blog 仓库
publish_branch: resume-dist # 空分支即可,会自动创建
publish_dir: ./public
commit_message: "chore: update resume dist"

二、改造 blog 主 Action(关键 4 行)

在你 blog 仓库.github/workflows/*.yml 里,找到 hexo g 之后、deploy 之前 的位置,插入:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 1. 拉取 resume 产物
- name: Fetch resume dist
uses: actions/checkout@v4
with:
repository: yourname/blog # 自己仓库
ref: resume-dist
token: ${{ secrets.GITHUB_TOKEN }}
path: resume-dist

# 2. 合并到主站 public/resume/
- name: Merge resume into public
run: |
mkdir -p public/resume
cp -r resume-dist/* public/resume/

然后继续你原来的 Deploy to username/username.github.io 步骤即可(peaceiris/actions-gh-pages 或 JamesIves/github-pages-deploy-action 都行)。

最终目录结构:

1
2
3
4
5
public/
index.html … # 博客
archives/ …
resume/ # 简历站点
index.html …

三、需要准备的 2 个 Secret

  1. resume 仓库 → Settings → Secrets → Actions
    新建 PAT:Personal Access Token,勾选 repo 权限,用于把产物推到 blog 仓库。

  2. blog 仓库
    如果原来已经配过推到 username.github.io 的 Token,无需再改;
    拉取 resume-dist 分支用默认 GITHUB_TOKEN 即可(同一仓库)。


四、验证流程

  1. 给 resume 推代码 →
    Action 绿 →
    打开 https://username.github.io/resume/ 就能看到最新简历。
  2. 给 blog 推代码 →
    主站 Action 绿 →
    博客 & 简历同时在线,互不影响。

可选优化

  • 给 resume 单独配主题、插件、甚至 Node 20 都行,主站完全无感。
  • 如果想再增加「portfolio」站点,同理再建一个 portfolio-dist 分支即可。