在github上快速部署一个基于hugo的个人博客

# 在github上快速部署一个基于hugo的个人博客

直接在github上搭建一个博客

第一次还是需要 本地装一次 hugo,我用的archlinux

yay -S hugo
hugo new site myblog
ls myblog

找一个自己喜欢的主题

    网站:https://themes.gohugo.io/
    或者github 搜索 hugo theme

有些 theme-demo 文件夹中会有 demo 或 example 目录,文件结构与新建的 Hugo 项目的文件结构几乎是一样的,这样设置是为了用户的配置可以覆盖掉主题的配置。

我选中了一个主题,下载到 themes文件夹里面

cd myblog
git clone https://github.com/chipzoller/hugo-clarity.git themes/hugo-clarity
cp -rf themes/hugo-clarity/exampleSite/* .
#\cp -rf themes/hugo-clarity/exampleSite/* .

把 myblog 里面的文件 上传到

新建一个 公开库 hugo

在 github上新建文件 如果复制出错 查看官方手册

.github/workflows/gh-pages.yml 可以从我这里复制 https://github.com/joyanhui/file.leiyanhui.com/blob/main/github-actions/hugo/public-to-gh-pages.yml

等待一会 github 执行完成后 会 自动创建一个 gh-pages 分支 里面是静态 文件,开启pages服务就好了

打开 https://joyanhui.github.io/hugo/ 查看

如果想要从一个私有库自动推送到一个共有库,先参考 之前的文章配置 ssh key 和变量,在修改

如果你复制出错,可以参考我的一个备份

https://github.com/joyanhui/file.leiyanhui.com/blob/main/github-actions/hugo/Private-to-public.yml

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计