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 的版本。


老哥留步,支持一下。

相关推荐
旅之灵夫3 分钟前
【GitHub项目推荐--HyperFrames:用 HTML 写视频,为 AI Agent 而生的渲染框架】
github
峰向AI30 分钟前
阿里内部用了2年的代码审查工具开源了:21k Star背后的「工业级」设计
github
zandy10111 小时前
2026vibe coding背后 :Kimi Code、Cursor、Claude Code、GitHub Copilot等五款工具架构演进全面分析
架构·github·copilot
zandy10111 小时前
网络支付合规三重门:Kimi Code、Cursor、GitHub Copilot等五款AI编程工具国内实战测评
github·copilot·ai编程
ssshooter3 小时前
Tauri + GitHub Actions 自动化发布 Android APK 技术总结
android·github·android studio
wdfk_prog4 小时前
GitHub push 失败:如何扫描并清理 Git 历史中的大文件
git·elasticsearch·github
Da Zeng5 小时前
快速搭建GitHub Page
github
明月_清风5 小时前
GitHub Actions 从入门到实战:一文搞懂 CI/CD 自动化
后端·ci/cd·github
QUOR6 小时前
Zorv AI 终端:基于 proot 沙箱的 Android 终端模拟器架构全解析
github
其实防守也摸鱼6 小时前
ZLibrary 类项目合规避坑指南:从技术实现到法律风险的全景梳理
运维·服务器·数据库·安全·自动化·github·copilot