我们经常发布文档更新,此页面的翻译可能仍在进行中。有关最新信息,请访问英文文档。如果此页面上的翻译有问题,请告诉我们

此版本的 GitHub Enterprise 将停止服务 此版本的 GitHub Enterprise 已停止服务 2020-05-23. 即使针对重大安全问题,也不会发布补丁。 要获得更好的性能、改进的安全性和新功能,请升级到 GitHub Enterprise 的最新版本。 如需升级方面的帮助,请联系 GitHub Enterprise 支持

文章版本: Enterprise Server 2.17

Creating a GitHub Pages site

You can create a GitHub Pages site in a new or existing repository.

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

本文内容

Creating a repository for your site

如果站点是一个独立的项目,您可以创建新仓库来存储站点源代码。 如果站点与现有项目关联, 您可以将站点的源代码添加到该项目仓库中的 gh-pages 分支或 master 分支上的 docs 文件夹。 例如,如果您创建站点来发布已经在 GitHub Enterprise 上的项目文档, 您可能想要将站点的源代码存储在与项目相同的仓库中。

如果要在现有仓库中创建站点,请跳至“创建站点”一节。

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

  1. 在任何页面的右上角,使用 下拉菜单选择 New repository(新建仓库)
    带有创建新仓库选项的下拉菜单
  2. 使用 Owner(所有者)下拉菜单选择你想要拥有仓库的帐户。
    所有者下拉菜单
  3. 输入仓库的名称和说明(可选)。 如果您创建的是用户或组织站点,仓库名称必须为 <user>.github.io<organization>.github.io。 更多信息请参阅“关于 GitHub Pages”。
    创建仓库字段
  4. 选择仓库可见性。 更多信息请参阅“关于仓库可见性”。
    选择仓库可见性的单选按钮
  5. 选择 Initialize this repository with a README(使用自述文件初始化此仓库)
    使用自述文件初始化此仓库复选框
  6. 单击 Create repository(创建仓库)

Creating your site

必须先在 GitHub Enterprise 上有站点的仓库,然后才可创建站点。 如果未在现有仓库中创建站点,请参阅“为站点创建仓库”。

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

  2. 如果您创建的是项目站点,请决定要使用哪个发布源。 如果您创建的是用户或组织站点,您必须将站点的源代码存储在 master 分支上。 更多信息请参阅“关于 GitHub Pages”。

  3. If your chosen publishing source already exists, navigate to the publishing source. If your chosen publishing source doesn't exist, create the publishing source.

  4. In the root of the publishing source, create a new file called index.md that contains the content you want to display on the main page of your site.

  5. 如果您使用的是项目站点的非默认发布源,请配置您的发布源。 更多信息请参阅“配置 GitHub Pages 站点的发布来源”。

  6. 在仓库名称下,单击 Settings(设置)

    仓库设置按钮

  7. 要查看您已发布的站点,请在“GitHub Pages”下点击您的站点 URL。

    已发布站点的 URL

    注:对站点的更改在推送到 GitHub Enterprise 后,最长可能需要 20 分钟才会发布。 如果一小时后仍然在浏览器中看不到您的更改,请参阅“关于 GitHub Pages 站点的 Jekyll 构建错误”。

:如果网站的源文件位于默认发布源 - master(对于用户和组织站点)或 gh-pages(对于项目站点)- 但您的站点未自动发布,请确保有一个拥有管理权限和经验证的电子邮件地址的人已推送到默认发布源。

后续步骤

You can add more pages to your site by creating more new files. Each file will be available on your site in the same directory structure as your publishing source. For example, if the publishing source for your project site is the gh-pages branch, and you create a new file called /about/contact-us.md on the gh-pages branch, the file will be available at http(s)://<hostname>/pages/<username>/<repository>/about/contact-us.md.

You can also add a theme to customize your site’s look and feel. For more information, see "Adding a theme to your GitHub Pages site using Jekyll."

To customize your site even more, you can use Jekyll, a static site generator with built-in support for GitHub Pages. 更多信息请参阅“关于 GitHub Pages 和 Jekyll”。

延伸阅读

问问别人

找不到要找的内容?

联系我们