GitHub 页面:将用户站点更改为项目站点

GitHub Pages: Changing User site to a Project site

去年,我将我的博客设置为 GitHub 页 "user site" 每个 GitHub Pages' instructions 按照他们的命名约定 username.github.io 在回购中。但是,现在我正在另一个站点上工作,我希望它位于 username.github.io 存储库中,然后将旧博客移动到一个新的存储库中,该存储库将是一个 "project site",仍然可以通过以下方式访问username.github.io/project_name

这只是重命名我的存储库的问题吗?或者我应该做些什么来确保平稳过渡?我找不到关于此的任何文档或其他帖子。

除了更改 repo 名称之外,您还需要更改分支名称。用户站点是从 master 分支中提取的,而项目站点是从 gh-pages 分支中提取的(当然,因为 master 已经被项目本身占用了)。

为了补充 fjarri 的回答,我想描述一下如果您的前 GitHub 页 User/Organization Page repo was using a CNAME file to redirect your GitHub domain (i.e. your_username.github.io) to a custom domain name (e.g., example.com) and how this interacts with a Project Page(s).

您应该怎么做

1) 在项目页面回购中(以前是您的 User/Organization 页面回购)

第 1 步: 确保 CNAME 文件已从 master gh-pages 中删除分支机构。

Why? GitHub Pages Project Pages use whatever domain is used by your GitHub Pages project site. So if your user site is using a CNAME file containing example.com, then your project site will appear under example.com/project_repo_name. If you aren't using a CNAME file in your user site, your project site is accessible via your_username.github.io/project_repo_name

Note: even if you have a CNAME file in your User/Organization Page repo, the URL in the settings of your Project Page will still display your_username.github.io -- Worry not! It will still display under your custom domain.

第 2 步: 为确保第 1 步有效,请转到项目站点存储库的设置页面,然后在 GitHub 页面标题下,您应该会看到类似“您的网站发布于 http://your_username.github.io/project_repo_name"。


2) 在新的 User/Organization 页面 Repo

按照用于初始设置 CNAME 文件的GitHub Page's documentation进行操作

Why? Because their docs are good