Hugo搭建博客

Hugo搭建博客

Hugo 安装

资源链接:gohugoiogohugo

  1. window下离线下载hugo.exe软件。

https://github.com/gohugoio/hugo/releases/hugo_extended_0.96.0_Windows-64bit.zip

  1. 环境配置,添加hugo.exe路径到PATH
  2. CMD测试,$hugo --version

Hugo 主题

主题库:themes

  1. 主题下载。
$ git init
$ git submodule add https://github.com/HEIGE-PCloud/DoIt.git themes/DoIt
  1. 主题配置:配置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仓库,并更新博客。

  1. 创建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
  1. 配置hugo-action.yml,参考link,注意external_repository值。

  2. 创建xxx.github.io仓库,构建github pages。

  3. 配置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
  1. 每当你同步更新blog仓库,自动会更新xxx.github.io仓库。
posted @ 2022-04-07 09:30  yangly1  阅读(130)  评论(0)    收藏  举报