From 31759b4842e637a3935ad9a221d6ccd75d570124 Mon Sep 17 00:00:00 2001 From: minlong Date: Wed, 7 Oct 2026 11:00:03 +0800 Subject: [PATCH] docs: clarify custom domain deployment variables --- README.en.md | 11 ++++++++++- README.md | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.en.md b/README.en.md index e056e9d5..a03e7cca 100644 --- a/README.en.md +++ b/README.en.md @@ -68,7 +68,7 @@ Pages use native browser scrolling. GSAP observes scroll position to animate rev 2. Push changes to `main` or `master`. The workflow installs locked dependencies, runs checks and tests, builds the website, and deploys it with the official GitHub Pages Actions. 3. You can also choose **Actions → Build and deploy Astro to GitHub Pages → Run workflow**. Only `main` and `master` deploy; Pull Requests run checks and builds. -The workflow reads the origin and base path from `actions/configure-pages`, supporting project sites, user sites, and configured custom domains. A normal `MyBlogDoc` project repository uses `/MyBlogDoc/`. Pull Request builds derive the path from `GITHUB_REPOSITORY`. Full Git history is checked out so article date fallbacks remain consistent. No PAT or manually maintained `gh-pages` branch is required. +The workflow reads the origin and base path from `actions/configure-pages`, supporting project sites, user sites, and configured custom domains. A normal `MyBlogDoc` project repository uses `/MyBlogDoc/`. Pull Request builds derive the path from `GITHUB_REPOSITORY` only when `BASE_PATH` is not set. Full Git history is checked out so article date fallbacks remain consistent. No PAT or manually maintained `gh-pages` branch is required. To override deployment settings, add repository variables under **Settings → Secrets and variables → Actions → Variables**: @@ -77,6 +77,15 @@ To override deployment settings, add repository variables under **Settings → S | `SITE_URL` | `https://momeak9.github.io` | Website origin without the project subpath | | `BASE_PATH` | `/MyBlogDoc/` | Project subpath; use `/` for root-domain deployment | +For the current custom domain `yihuiblog.top`, set these **Repository Variables**: + +```ini +SITE_URL=https://yihuiblog.top +BASE_PATH=/ +``` + +The custom domain serves the website at the root path `/`. These variables take priority over automatic GitHub Pages configuration and are also used for Pull Request builds. Keep the root path instead of the project-site `/MyBlogDoc/` prefix; see the [Astro custom domain deployment guide](https://docs.astro.build/en/guides/deploy/github/#change-your-github-url-to-a-custom-domain). After changing them, run the workflow again for the settings to take effect; you can manually run it on `main` from **Actions → Build and deploy Astro to GitHub Pages → Run workflow**. + Local development defaults to `/`. To verify the same project path used in CI: ```sh diff --git a/README.md b/README.md index 30244c2a..01e57c56 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ star: true 2. 将修改提交到 `main` 或 `master`。工作流依次安装锁定依赖、执行检查与测试、构建静态站点,再使用 GitHub 官方 Pages Actions 部署。 3. 也可以在 **Actions → Build and deploy Astro to GitHub Pages → Run workflow** 手动运行。只有 `main`、`master` 会部署;Pull Request 会检查和构建。 -工作流读取 `actions/configure-pages` 输出的站点域名与路径,支持项目站点、用户站点和已配置的自定义域名。对于普通 `MyBlogDoc` 项目仓库,路径为 `/MyBlogDoc/`。Pull Request 构建根据 `GITHUB_REPOSITORY` 推导对应路径。Git 历史完整检出,以保持无日期文章的时间一致。部署不需要 PAT 或手工维护 `gh-pages` 分支。 +工作流优先读取 Repository Variables;未设置时读取 `actions/configure-pages` 输出的站点域名与路径,支持项目站点、用户站点和已配置的自定义域名。对于普通 `MyBlogDoc` 项目仓库,路径为 `/MyBlogDoc/`。Pull Request 构建在未设置 `BASE_PATH` 时根据 `GITHUB_REPOSITORY` 推导对应路径。Git 历史完整检出,以保持无日期文章的时间一致。部署不需要 PAT 或手工维护 `gh-pages` 分支。 需要覆盖地址时,在 **Settings → Secrets and variables → Actions → Variables** 中设置: @@ -77,6 +77,15 @@ star: true | `SITE_URL` | `https://momeak9.github.io` | 站点域名,不含项目子路径 | | `BASE_PATH` | `/MyBlogDoc/` | 项目部署路径;根域名部署设置为 `/` | +当前自定义域名 `yihuiblog.top` 部署在根路径 `/`,请明确设置以下 Repository Variables: + +```ini +SITE_URL=https://yihuiblog.top +BASE_PATH=/ +``` + +这两个变量优先于 Pages 自动推导,也会应用于 Pull Request 构建。自定义域名下的路径为 `/`,不要沿用普通项目站点的 `/MyBlogDoc/` 前缀;参见 [Astro 自定义域名部署说明](https://docs.astro.build/en/guides/deploy/github/#change-your-github-url-to-a-custom-domain)。修改变量后,需要下一次工作流构建才能生效;可按上方步骤手动运行 `main` 分支。 + 本地开发默认路径为 `/`。可用与 CI 相同的变量验证项目路径: ```sh