操作步骤

1. 购买域名

在 Cloudflare Registrar 购入 attack825.party,NS 托管在 Cloudflare。

2. 添加 DNS 记录

代理状态全部为仅 DNS(灰云),让流量直接落到 GitHub 的边缘节点。

类型名称内容
CNAME@attack825.github.io
CNAMEwwwattack825.github.io

3. 配置 GitHub Pages

仓库 Settings → Pages → Custom domain 填 attack825.party 并保存,等 DNS check 通过、证书签发完成。

4. 修改 hugo.toml

baseURL = "https://attack825.party/"

5. 新增 static/CNAME

attack825.party

GitHub 在 Pages 后台会自动生成 CNAME,但部署脚本用 robocopy /MIR 镜像同步 public/,会把不在构建产物里的文件删掉。放进 static/ 后每次构建都会带上。

6. 修改 deploy.ps1

把硬编码的站点地址改成从 hugo.toml 读取:

$baseURLMatch = Select-String -Path (Join-Path $root 'hugo.toml') -Pattern '^baseURL\s*=\s*"([^"]+)"' | Select-Object -First 1
if (-not $baseURLMatch) { throw '无法从 hugo.toml 读取 baseURL' }
$siteUrl = $baseURLMatch.Matches[0].Groups[1].Value
if (-not $siteUrl.EndsWith('/')) { $siteUrl += '/' }

7. 构建并发布

.\deploy.ps1

构建、镜像同步、提交、推送到部署仓库一次完成,脚本内的 SRI 校验通过。

8. 验证

检查项结果
首页 HTTPS200,Server 为 GitHub.com
canonicalhttps://attack825.party/
sitemap / robots / RSS全部指向新域名
旧域名根路径301 到新域名
旧域名文章深链301 到新域名
www301 到根域名
不存在的路径404