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/
→ 最后统一 push
到 username.github.io
的 gh-pages
。”
这样做的好处:
- resume 源码完全私有;
- 主站 Action 只拉产物,不拉源码;
- 对
username.github.io
来说只是多了一个/resume
目录,毫无感知。
一、给 resume 仓库配极简 Action
文件:.github/workflows/build.yml
(放在 resume 仓库)
1 | name: Build Resume Hexo |
二、改造 blog 主 Action(关键 4 行)
在你 blog 仓库 的 .github/workflows/*.yml
里,找到 hexo g 之后、deploy 之前 的位置,插入:
1 | # 1. 拉取 resume 产物 |
然后继续你原来的 Deploy to username/username.github.io 步骤即可(peaceiris/actions-gh-pages 或 JamesIves/github-pages-deploy-action 都行)。
最终目录结构:
1 | public/ |
三、需要准备的 2 个 Secret
-
在 resume 仓库 → Settings → Secrets → Actions
新建PAT
:Personal Access Token,勾选repo
权限,用于把产物推到 blog 仓库。 -
在 blog 仓库
如果原来已经配过推到username.github.io
的 Token,无需再改;
拉取resume-dist
分支用默认GITHUB_TOKEN
即可(同一仓库)。
四、验证流程
- 给 resume 推代码 →
Action 绿 →
打开https://username.github.io/resume/
就能看到最新简历。 - 给 blog 推代码 →
主站 Action 绿 →
博客 & 简历同时在线,互不影响。
可选优化
- 给 resume 单独配主题、插件、甚至 Node 20 都行,主站完全无感。
- 如果想再增加「portfolio」站点,同理再建一个
portfolio-dist
分支即可。