<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>GitHub Pages on IMX-博客</title><link>https://blog.cbzmx.com/tags/github-pages/</link><description>Recent content in GitHub Pages on IMX-博客</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Sat, 26 Sep 2026 12:00:00 +0800</lastBuildDate><atom:link href="https://blog.cbzmx.com/tags/github-pages/index.xml" rel="self" type="application/rss+xml"/><item><title>Hugo 博客部署到 GitHub Pages 完全指南</title><link>https://blog.cbzmx.com/posts/github-pages-deployment-guide/</link><pubDate>Sat, 13 Jun 2026 00:00:00 +0000</pubDate><guid>https://blog.cbzmx.com/posts/github-pages-deployment-guide/</guid><description>&lt;p&gt;本篇从一个已经能运行 &lt;code&gt;hugo --minify&lt;/code&gt; 的博客开始。还没有站点，可以先完成 &lt;a href="https://blog.cbzmx.com/posts/hugo-imx-theme-tutorial/"&gt;Hugo 与 IMX 入门指南&lt;/a&gt;；需要调整主题细节，参见 &lt;a href="https://blog.cbzmx.com/posts/hugo-theme-imx-configuration-guide/"&gt;IMX 主题配置指南&lt;/a&gt;。&lt;/p&gt;&#10;&lt;p&gt;&lt;img&#10; src="https://blog.cbzmx.com/posts/github-pages-deployment-guide/images/cover-v2.webp"&#10; alt="从本地博客经工作流发布到 GitHub Pages 的概念图"&#10; width="1672"&#10; height="941"&#10; loading="lazy"&#10; decoding="async"&gt;&lt;/p&gt;&#10;&lt;h2 id="1-确认仓库与站点地址"&gt;1. 确认仓库与站点地址&lt;/h2&gt;&#10;&lt;p&gt;GitHub Pages 有两种常见地址，&lt;code&gt;baseURL&lt;/code&gt; 必须与最终公开地址对应：&lt;/p&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;类型&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;仓库名&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;code&gt;baseURL&lt;/code&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;用户站点&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;your-name.github.io&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;https://your-name.github.io/&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;项目站点&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;my-blog&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;https://your-name.github.io/my-blog/&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;本站是用户站点，但使用自定义域名，所以 &lt;code&gt;hugo.toml&lt;/code&gt; 中写的是 &lt;code&gt;baseURL = 'https://blog.cxx.pub/'&lt;/code&gt;。项目站点尤其要保留末尾的仓库路径；否则页面链接、图片或样式可能指向错误位置。&lt;/p&gt;&#10;&lt;p&gt;在发布前检查本地环境与构建：&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hugo version&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;go version&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hugo --minify&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;IMX 需要 Hugo Extended 和 Go。Hugo Module 的依赖应记录在 &lt;code&gt;go.mod&lt;/code&gt;、&lt;code&gt;go.sum&lt;/code&gt;，并连同 &lt;code&gt;hugo.toml&lt;/code&gt; 一起提交。将 &lt;code&gt;/public/&lt;/code&gt;、&lt;code&gt;/resources/_gen/&lt;/code&gt;、&lt;code&gt;/.hugo_build.lock&lt;/code&gt; 放入 &lt;code&gt;.gitignore&lt;/code&gt;；Pages 工作流会构建 &lt;code&gt;public/&lt;/code&gt;，不必把它提交进源码仓库。&lt;/p&gt;&#10;&lt;h2 id="2-创建-github-仓库"&gt;2. 创建 GitHub 仓库&lt;/h2&gt;&#10;&lt;p&gt;在 GitHub 新建仓库。若希望使用根地址 &lt;code&gt;https://your-name.github.io/&lt;/code&gt;，仓库名必须是 &lt;code&gt;your-name.github.io&lt;/code&gt;；若使用项目地址，可以取普通仓库名。已有本地 Git 仓库时，建议创建空仓库，避免首次推送出现不必要的历史合并。&lt;/p&gt;&#10;&lt;p&gt;然后在仓库 &lt;strong&gt;Settings → Pages → Build and deployment → Source&lt;/strong&gt; 选择 &lt;strong&gt;GitHub Actions&lt;/strong&gt;。本文的工作流会上传构建产物并部署，不使用“从分支发布”的方式。&lt;/p&gt;</description></item></channel></rss>