这个blog是怎么发布的

自从把这个blog迁移到Hugo之后就没有写过任何文章,以至于研究了一会才明白这个流程。

基本的流程很简单,把改动推送到https://github.com/4179e1/poetpalace, 然后Github Workflow 会完成剩下的步骤。但是这个步骤缺失了很多细节,这次就来记录一下吧。

0. 安装Hugo

参考https://gohugo.io/installation/

1. Clone Repo

Hugo的主题是通过git submodule管理的,因此git clone的时候需要连同所有submodule clone下来

git clone --recurse-submodules git@github.com:4179e1/poetpalace.git

如果clone的时候忘了包含submodules,可以执行

git submodule update --init --recursive

Note: 我目前使用的主题是meme

2. 创建新内容

hugo new conent path_to/doc.md

执行完后hugo会在content/path_do/doc.md下创建对应的新文件,它使用archetypes\default.md作为模板。 如果错误的使用了content/path_to/doc.md作为路径,它会无法匹配这个模板而使用内置的默认模板创建新文档。

3. 提供新内容

直接编辑新创建的文件即可,如果需要预览,可以执行

hugo serve

然后打开浏览器访问[http://localhost:1313]

4. Push 到 Github 并触发Github workflow

当Github收到推送时,Github workflow会读取.github\workflows\pipeline.yaml并执行对应的操作

  1. Setup Hugo: 使用了peaceiris/actions-hugo@v2这个Github Action。
  2. Build:调用hugo --minify
  3. deploy: 调用pipeline\deploy.sh,本质上它使用ssh key把生成的内容scp到云主机上。这个key保存在Github repo的Actions secrets and variables

Appendix 1. 如何更新主题

git submodule update --remote --recursive

Appendix 2. What about http://poetpalace.org?

这个页面使用类似的方式发布,但是它之后静态页面,因此完全跳过了Hugo相关的内容。

updatedupdated2026-02-252026-02-25