一、打开power shell窗口 Link to heading
- 安装 hugo:winget install Hugo.Hugo.Extended
- 创建 hugo 项目:hugo new site pblog
- 进入项目:cd pblog
- 复制主题:git clone https://github.com/luizdepra/hugo-coder.git themes/hugo-coder
- 配置 hugo.toml,可以使用主题作者提供的示例
- 删掉主题库 .git:rmdir /s /q themes\hugo-coder.git,避免影响后续推送
- 运行 hugo 验证是否可以成功构建:hugo
二、托管至 Github Link to heading
- git init
- git add .
- git commit -m “Initial”
- 在 Github 上创建一个仓库,可以是私有仓库,设置本地项目 Git 远程地址到仓库:git remote add origin https://github.com//.git
- git push -u origin master 或 git push -u origin main
- 到仓库验证本地代码已推送
三、部署至 Cloudflare Pages Link to heading
- 进入 Cloudflare - 构建 - Compute - Workers 和 Pages 页面,点击创建应用程序,选择 Pages。首次使用时,需要绑定和授权 Github 账号
- 在创建应用程序页面,选择要部署的项目对应仓库,选择静态框架为 hugo,快速部署,完成后使用 Cloudflare Pages 提供的默认域名访问网页
- 如构建失败,可能是 Hugo 版本差异,需要指定 HUGO_VERSION 环境变量