跳至主要内容

GitHub Pages 快速入门

您可以使用 GitHub Pages 来展示一些开源项目、托管博客,甚至分享您的简历。本指南将帮助您快速开始创建下一个网站。

谁可以使用此功能?

GitHub Pages 在公共仓库中可使用 GitHub Free 和组织的 GitHub Free;在公共和私有仓库中可使用 GitHub Pro、GitHub Team、GitHub Enterprise Cloud 和 GitHub Enterprise Server。欲了解更多信息,请参阅 GitHub 的套餐

简介

在本指南中,您将创建一个位于 <username>.github.io 的用户站点。

创建您的网站

  1. 在任意页面的右上角,选择,然后点击 新建仓库

    Screenshot of a GitHub dropdown menu showing options to create new items. The menu item "New repository" is outlined in dark orange.

  2. username.github.io 设为仓库名称。将 username 替换为您的 GitHub 用户名。例如,如果您的用户名是 octocat,则仓库名称应为 octocat.github.io

    Screenshot of GitHub Pages settings in a repository. The repository name field contains the text "octocat.github.io" and is outlined in dark orange.

  3. 选择仓库可见性。欲了解更多信息,请参阅 关于仓库

  4. Add README 切换为 On

  5. 点击 创建仓库

  6. 在您的仓库名称下,点击 设置。如果看不到 “Settings” 选项卡,请选择 下拉菜单,然后点击 设置

    Screenshot of a repository header showing the tabs. The "Settings" tab is highlighted by a dark orange outline.

  7. 在侧边栏的“代码和自动化”部分,点击 Pages

  8. 在 “Build and deployment” 下的 “Source” 中,选择 从分支部署

  9. 在 “Build and deployment” 下的 “Branch” 中,使用分支下拉菜单并选择一个发布源。

    Screenshot of Pages settings in a GitHub repository. A menu to select a branch for a publishing source, labeled "None," is outlined in dark orange.

  10. 您也可以打开仓库的 README.md 文件。README.md 文件是您撰写站点内容的地方。您可以编辑该文件,或暂时保留默认内容。

  11. 访问 username.github.io 查看您的新网站。请注意,推送更改到 GitHub 后,站点的更新可能需要最长 10 分钟才能发布。

更改标题和描述

默认情况下,您的站点标题为 username.github.io。您可以通过编辑仓库中的 _config.yml 文件来更改标题,也可以为站点添加描述。

  1. 点击仓库的 代码 选项卡。

  2. 在文件列表中,点击 _config.yml 打开文件。

  3. 点击编辑文件。

  4. _config.yml 文件已经包含一行指定站点主题的配置。添加一行以 title: 开头,后跟您想要的标题。再添加一行以 description: 开头,后跟您想要的描述。例如

    theme: jekyll-theme-minimal
    title: Octocat's homepage
    description: Bookmark this to keep an eye on my project updates!
    
  5. 编辑完成后,点击 提交更改

下一步

您已成功创建、个性化并发布了第一个 GitHub Pages 网站,但还有更多内容值得探索!以下是帮助您在 GitHub Pages 上迈出下一步的一些资源

© . This site is unofficial and not affiliated with GitHub, Inc.