Hugo搭建博客
Hugo搭建博客
Hugo 安装
- window下离线下载
hugo.exe软件。
https://github.com/gohugoio/hugo/releases/hugo_extended_0.96.0_Windows-64bit.zip
- 环境配置,添加
hugo.exe路径到PATH。 - CMD测试,
$hugo --version。
Hugo 主题
主题库:themes。
- 主题下载。
$ git init
$ git submodule add https://github.com/HEIGE-PCloud/DoIt.git themes/DoIt
- 主题配置:配置TOML,doit。
Hugo 博客
# 创建博客站点
$ hugo new site blog
$ cd blog
# 创建文章
$ hugo new posts/first_post.md
# 临时
$ hugo server -D
# 构建网站
$ hugo
Hugo 部署
参考链接:link。
Github部署 + Hugo页面:思路是blog保存hugo博客资源,利用githbu action机制同步博客页到xxx.github.io仓库,并更新博客。
- 创建
blog仓库,同步blog站点。
$ cd blog # 到站点文件夹
$ git init
$ git add .
$ git branch -M main
$ git remote add origin https://github.com/xxx/blog.git
$ git push -u origin main
-
配置
hugo-action.yml,参考link,注意external_repository值。 -
创建
xxx.github.io仓库,构建github pages。 -
配置ssh-key:
xxx.github.io仓库->settings -> Deploy keys -> ACTIONS_DEPLOY_KEY -> Public Key -> Allow write access;blog仓库 -> settings -> Secrets -> ACTIONS_DEPLOY_KEY -> Private Key。
$ ssh-keygen -t rsa -C "xxx@xxx.com" -f ~\.ssh\id_rsa_hugo_deploy
- 每当你同步更新
blog仓库,自动会更新xxx.github.io仓库。

浙公网安备 33010602011771号