Skip to main content

About GitHub Pages

You can use GitHub Pages to host a website about yourself, your organization, or your project directly from a repository on GitHub.com.

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

About GitHub Pages

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

You can host your site on GitHub's github.io domain or your own custom domain. For more information, see "Using a custom domain with GitHub Pages."

除非您的企业使用 企业托管用户,否则您可以选择通过管理站点的访问控制来公开或私下发布项目站点。 For more information, see "Changing the visibility of your GitHub Pages site."

To get started, see "Creating a GitHub Pages site."

Organization owners can disable the publication of GitHub Pages sites from the organization's repositories. For more information, see "Managing the publication of GitHub Pages sites for your organization."

Types of GitHub Pages sites

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

To publish a user site, you must create a repository owned by your personal account that's named <username>.github.io. To publish an organization site, you must create a repository owned by an organization that's named <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)://<username>.github.io/<repository> or http(s)://<organization>.github.io/<repository>.

If you publish your site privately, the URL for your site will be different. For more information, see "Changing the visibility of your GitHub Pages site."

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

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

Publishing sources for GitHub Pages sites

警告:除非您的企业使用 企业托管用户,否则 GitHub Pages 站点在默认情况下在互联网上公开可用,即使站点的存储库是私有的或内部的。 您可以通过管理网站的访问控制来私下发布网站。 否则,如果站点的仓库中有敏感数据,您可能想要在发布前删除它。 更多信息请参阅“关于存储库”和“更改 GitHub Pages 站点的可见性”。

You can publish your site when changes are pushed to a specific branch, or you can write a GitHub Actions workflow to publish your site.

If you do not need any control over the build process for your site, we recommend that you publish your site when 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.

If you want to use a build process other than Jekyll or you do not want a dedicated branch to hold your compiled static files, we recommend that you write a GitHub Actions workflow to publish your site. GitHub Enterprise Cloud provides starter workflows for common publishing scenarios to help you write your workflow.

For more information, see "Configuring a publishing source for your GitHub Pages site."

Limitations for 企业托管用户

If you're a 托管用户帐户, your use of GitHub Pages is limited.

  • GitHub Pages sites can only be published from repositories owned by organizations.
  • GitHub Pages sites are only visible to other members of the enterprise.

For more information about 企业托管用户, see "About 企业托管用户."

Static site generators

GitHub Pages 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. You can also customize your own build process locally or on another server.

If you use a custom build process or a static site generator other than Jekyll, you can write a GitHub Actions to build and publish your site. GitHub Enterprise Cloud provides starter workflows for several static site generators. For more information, see "Configuring a publishing source for your GitHub Pages site."

If you publish your site from a source branch, GitHub Pages will use Jekyll to build your site by default. If you want to use a static site generator other than Jekyll, we recommend that you write a GitHub Actions to build and publish your site instead. Otherwise, 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 Pages does not support server-side languages such as PHP, Ruby, or Python.

Limits on use of GitHub Pages

GitHub Pages sites created after June 15, 2016, and using github.io domains are served over HTTPS. If you created your site before June 15, 2016, you can enable HTTPS support for traffic to your site. For more information, see "Securing your GitHub Pages with HTTPS."

Prohibited uses

GitHub Pages is not intended for or allowed to be used as a free web-hosting service to run your online business, e-commerce site, or any other website that is primarily directed at either facilitating commercial transactions or providing commercial software as a service (SaaS). GitHub Pages 站点不应该用于敏感事务,例如发送密码或信用卡号码。

In addition, your use of GitHub Pages is subject to the GitHub Terms of Service, including the restrictions on get-rich-quick schemes, sexually obscene content, and violent or threatening content or activity.

Usage limits

GitHub Pages sites are subject to the following usage limits:

  • GitHub Pages source repositories have a recommended limit of 1 GB. For more information, see "What is my disk quota?"

  • Published GitHub Pages sites may be no larger than 1 GB.

  • GitHub Pages sites have a soft bandwidth limit of 100 GB per month.

  • GitHub Pages sites have a soft limit of 10 builds per hour. This limit does not apply if you build and publish your site with a custom GitHub Actions workflow

  • In order to provide consistent quality of service for all GitHub Pages sites, rate limits may apply. These rate limits are not intended to interfere with legitimate uses of GitHub Pages. If your request triggers rate limiting, you will receive an appropriate response with an HTTP status code of 429, along with an informative HTML body.

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 Support 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.

MIME types on GitHub Pages

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 Pages 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 Pages. For more information, see the mime-db contributing guidelines.

Further reading