lamess / Hugo搭建

Created Tue, 04 Jun 2024 10:11:21 +0800 Modified Tue, 14 Jan 2025 17:37:25 +0800
322 Words

Hugo+GitHub+Cloudflare Pages 搭建记录

Hugo环境部署

按照官方指引,先进行Hugo的安装。安装完成后,初始化博客目录。

hugo new site blog
cd blog
hugo new post/blog.md
git init
git submodule add https://github.com/lamess233/github-style.git themes/github-style

将Hugo上传到Git

git init
git remote add origin git@github.com:username/reponame:git
git add -A
git commit -m "initial commit"
git push -u origin main

使用Cloudflare Pages部署

登录Cloudflare,创建Page并连接至Git项目。
框架预设为HUGO,构建输出目录填写/public(注意上传至Git时将public目录清空)。
构建命令使用git fetch --unshallow && hugo --baseURL="https://blog.233323333.xyz"
环境变量填写HUGO的版本:HUGO_VERSION = 0.126.1

使用触发器将页面绑定到个人的域名,即可将博客发布至Cloudfalre。