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

About GitHub Pages

You can use GitHub 页面 to host a website about yourself, your organization, or your project directly from a GitHub repository.

GitHub 页面 可用于具有 GitHub Free 的公共仓库,以及具有 GitHub Pro、GitHub Team、GitHub Enterprise Cloud 和 GitHub Enterprise Server 的公共和私有仓库。更多信息请参阅“GitHub 的产品。”

本文内容

关于 GitHub 页面

GitHub 页面 is a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub, optionally runs the files through a build process, and publishes a website. You can see examples of GitHub 页面 sites in the GitHub 页面 examples collection.

You can host your site on GitHub's github.io domain or your own custom domain. 更多信息请参阅“对 GitHub 页面 使用自定义域”。

To get started, see "Creating a GitHub 页面 site."

Types of GitHub 页面 sites

There are three types of GitHub 页面 sites: project, user, and organization. Project sites are connected to a specific project hosted on GitHub, such as a JavaScript library or a recipe collection. User and organization sites are connected to a specific GitHub account.

User and organization sites are always published from a repository named <user>.github.io or <organization>.github.io. Unless you're using a custom domain, user and organization sites are available at http(s)://<username>.github.io or http(s)://<organization>.github.io.

The source files for a project site are stored in the same repository as their project. Unless you're using a custom domain, project sites are available at http(s)://<user>.github.io/<repository> or http(s)://<organization>.github.io/<repository>.

For more information about how custom domains affect the URL for your site, see "About custom domains and GitHub 页面."

You can only create one user or organization site for each GitHub account. Project sites, whether owned by an organization or a user account, are unlimited.

Note: Repositories using the legacy <user>.github.com naming scheme will still be published, but visitors will be redirected from http(s)://<username>.github.com to http(s)://<username>.github.io. If both a <user>.github.com and <user>.github.io repository exist, only the <user>.github.io repository will be published.

Publishing sources for GitHub 页面 sites

The publishing source for your GitHub 页面 site is the branch or folder where the source files for your site are stored. All sites have a default publishing source, and project sites have additional publishing sources available.

警告:GitHub 页面 站点在互联网上向公众开放,即使其仓库是私有的。如果您的页面仓库中有敏感数据,可能需要在发布之前将其删除。

The default publishing source for user and organization sites is the master branch. If the repository for your user or organization site has a master branch, your site will publish automatically from that branch. You cannot choose a different publishing source for user or organization sites.

The default publishing source for a project site is the gh-pages branch. If the repository for your project site has a gh-pages branch, your site will publish automatically from that branch.

Project sites can also be published from the master branch or a /docs folder on the master branch. To publish your site from one of these sources, you must configure a different publishing source. For more information, see "Configuring a publishing source for your GitHub 页面 site."

If you choose the /docs folder of the master branch as your publishing source, GitHub 页面 will read everything to publish your site, including the CNAME file, from the /docs folder. For example, when you edit your custom domain through the GitHub 页面 settings, the custom domain will write to /docs/CNAME. For more information about CNAME files, see "Managing a custom domain for your GitHub 页面 site."

Static site generators

GitHub 页面 publishes any static files that you push to your repository. You can create your own static files or use a static site generator to build your site for you. 您还可以在本地或其他服务器上自定义自己的构建过程。 We recommend Jekyll, a static site generator with built-in support for GitHub 页面 and a simplified build process. For more information, see "About GitHub 页面 and Jekyll."

GitHub 页面 will use Jekyll to build your site by default. If you want to use a static site generator other than Jekyll, disable the Jekyll build process by creating an empty file called .nojekyll in the root of your publishing source, then follow your static site generator's instructions to build your site locally.

GitHub 页面 does not support server-side languages such as PHP, Ruby, or Python.

Guidelines for using GitHub 页面

使用限制

GitHub 页面 站点受到以下使用限制的约束:

If your site exceeds these usage quotas, we may not be able to serve your site, or you may receive a polite email from GitHub 支持GitHub 高级支持 suggesting strategies for reducing your site's impact on our servers, including putting a third-party content distribution network (CDN) in front of your site, making use of other GitHub features such as releases, or moving to a different hosting service that might better fit your needs.

Prohibited uses

GitHub 页面 并非旨在用于或允许用作免费的 Web 托管服务来运行您的在线业务、电子商务站点或主要针对促进商业交易或提供商业软件即服务 (SaaS) 的任何其他网站。

此外,GitHub 页面 站点必须避免:

如果您对用途或预期用途是否归入这些类别有疑问,请联系 GitHub 支持GitHub 高级支持

MIME types on GitHub 页面

A MIME type is a header that a server sends to a browser, providing information about the nature and format of the files the browser requested. GitHub 页面 supports more than 750 MIME types across thousands of file extensions. The list of supported MIME types is generated from the mime-db project.

While you can't specify custom MIME types on a per-file or per-repository basis, you can add or modify MIME types for use on GitHub 页面. For more information, see the mime-db contributing guidelines.

延伸阅读

问问别人

找不到要找的内容?

联系我们