Skip to main content

配置 GitHub Pages 站点的发布源

If you use the default publishing source for your GitHub Pages site, your site will publish automatically. You can also choose to publish your site from a different branch or folder.

People with admin or maintainer permissions for a repository can configure a publishing source for a GitHub Pages site.

GitHub Pages 适用于具有 GitHub Free 和组织的 GitHub Free 的公共仓库,以及具有 GitHub Pro、GitHub Team、GitHub Enterprise Cloud 和 GitHub Enterprise Server 的公共和私有仓库。

About publishing sources

Your GitHub Pages site will publish whenever changes are pushed to a specific branch. You can specify which branch and folder to use as your publishing source. The source branch can be any branch in your repository, and the source folder can either be the root of the repository (/) on the source branch or a /docs folder on the source branch. Whenever changes are pushed to the source branch, the changes in the source folder will be published to your GitHub Pages site.

警告:如果您的站点管理员启用了公共页面, 则 GitHub Pages 站点在互联网上公开可用,即使站点的存储库是私有的或内部的。 如果站点的仓库中有敏感数据,您可能想要在发布前删除它。 更多信息请参阅“为企业配置 GitHub Pages”和“关于存储库”。

Publishing from a branch

  1. Make sure the branch you want to use as your publishing source already exists in your repository.

  2. 在 GitHub Enterprise Server 上,导航到站点的仓库。

  3. 在仓库名称下,单击 Settings(设置)仓库设置按钮

  4. 在左侧边栏中,单击 Pages(页面)左侧边栏中的页面选项卡

  5. 在“GitHub Pages”下,使用 None(无)Branch(分支)下拉菜单选择发布源。 用于选择发布源的下拉菜单

  6. (可选)使用下拉菜单选择发布源的文件夹。 用于选择发布源文件夹的下拉菜单

  7. 单击 Save(保存)用于保存对发布源设置的更改的按钮

Troubleshooting publishing from a branch

Note: If your site has not published automatically, make sure someone with admin permissions and a verified email address has pushed to the publishing source.

如果选择任意分支上的 docs 文件夹作为发布源,然后从仓库的该分支中删除了 /docs 文件夹,则您的站点将不会构建,并且您将收到提示缺失 /docs 文件夹的页面构建错误。 更多信息请参阅“关于 GitHub Pages 站点的 Jekyll 构建错误疑难排解”。