github pages + hugo 搭建静态博客网站

体验地址

1. 起因, 目的:

  1. 其实6年前,我就写过这个。
    项目代码
    博客地址

  2. 最近想改写一下。

    github 推荐的主题是 Jekyll, 我当时用的就是这个,感觉很麻烦。尤其是文章命名。

  3. 新的主题 hugo 用起来还行。

2.过程:

过程记录, 需要详细! 因为问题非常多!

3. 参考教程:

  1. 视频教程: https://www.youtube.com/watch?v=_QSr2_pxIJs
  2. 配置文件,参考来源: https://theplaybook.dev/docs/deploy-hugo-to-github-pages/
一句话介绍 hugo:

hugo 是一个静态博客渲染工具, go 语言写的。

安装:

choco install hugo-extended # 失败。 估计是权限

scoop install hugo-extended # ok!

运行的话, 最好是使用 wsl , cmd 也行!!
新 hugo 建项目

hugo new site my_hugo_blog -f yaml

cd my_hugo_blog

安装主题,

git init

git clone https://github.com/adityatelange/hugo-PaperMod themes/PaperMod --depth=1

git submodule add --depth=1 https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod

修改 "hugo.toml", 增加一行

theme = "PaperMod"

新建文章

hugo new docs/test_file.md

!!! !!!

draft = true, ----> draft = false 否则无法渲染。 直接删掉这一行也行。

!! !!! !!! !!!

查看文章: localhost:7897/docs/test_file

下面就 github 相关的操作了
  • 创建github 项目,上传文件。
  • 新建一个分支, gh-pages !!! 这里名称不能变。 必须是 gh! 一个字都不能变!
  • 开启 github actions 读写权限 https://github.com/buxuele/my_hugo_blog/settings/actions
  • mkdir -p .github/workflows, 新建+修改 deploy.yml
  • 修改 "hugo.toml", 增加 baseUrl
报错:

其实就是修改一个 hugo 的版本。


老哥留步,支持一下。

相关推荐
老马啸西风4 小时前
sensitive-word-admin v2.0.0 全新 ui 版本发布!vue+前后端分离
vue.js·ui·ai·nlp·github·word
是代码侠呀5 小时前
飞蛾扑火算法matlab实现
开发语言·算法·matlab·github·github star·github 加星
大龄牛码7 小时前
GitHub打开缓慢甚至失败的解决办法
github
柯ran11 小时前
JSON|cJSON 介绍以及具体项目编写
c语言·链表·json·github
正经教主12 小时前
【问题】Watt加速github访问速度:好用[特殊字符]
github·watt
wumu_Love12 小时前
git 报错:错误:RPC 失败。curl 28 Failed to connect to github.com port 443 after 75000
git·rpc·github
qianmoQ1 天前
GitHub 趋势日报 (2025年05月09日)
github
是代码侠呀1 天前
HTTP 的发展史:从前端视角看网络协议的演进
前端·网络协议·http·开源·github·github star·github 加星
jz_ddk1 天前
[学习]RTKLib详解:rtksvr.c与streamsvr.c
c语言·学习·github
是代码侠呀2 天前
让Promise飞,让github star 飞
python·开源·github·github star·github 加星