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


老哥留步,支持一下。

相关推荐
fthux5 小时前
RenoPit 能为普通业主做什么?看懂图纸、审查合同,提前发现装修坑
javascript·人工智能·ai·开源·github·chrome扩展·open source·edge扩展·firefox扩展
码流怪侠9 小时前
【GitHub】Bend:让 GPU 并行编程像写 Python 一样简单
python·github
炸膛坦客9 小时前
Git 和 GitHub:(九)修改本地仓库内容并推送到远程仓库(关联/克隆)
git·github
lazy H12 小时前
Git clone 怎么用?克隆项目及常见问题完整教程
大数据·git·后端·学习·搜索引擎·github
m0_7436975914 小时前
关于ftp与SELinux的冲突问题
git·github
凌奕15 小时前
我读了六个 Coding Agent 的上下文压缩源码,发现网上流传的数据一半是错的
github·agent·claude
一次旅行19 小时前
act本地预跑GitHub Actions:Python项目完整CI/CD流水线实战
python·ci/cd·github
敢敢是只喵i20 小时前
Agent 为什么需要 guidance,但不能把 guidance 当成安全策略?
github·aigc
不简说20 小时前
JS 代码技巧 vol.9 — 20 个设计模式在真实项目里的应用
前端·javascript·github
逛逛GitHub21 小时前
很多神级开源 Agent 从它演化而来:77K Star 的 Pi 太强了。
github