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

此版本的 GitHub Enterprise 将停止服务 此版本的 GitHub Enterprise 已停止服务 2019-10-16. 即使针对重大安全问题,也不会发布补丁。 For better performance, improved security, and new features, upgrade to the latest version of GitHub Enterprise. For help with the upgrade, contact GitHub Enterprise support.

关于 GitHub Pages 和 Jekyll

Jekyll is a static site generator with built-in support for GitHub 页面.

GitHub 页面 可用于具有 GitHub Free 的公共仓库,以及具有 GitHub Pro、GitHub Team、GitHub Enterprise Cloud 和 GitHub Enterprise Server 的公共和私有仓库。

本文内容

About Jekyll

Jekyll is a static site generator with built-in support for GitHub 页面 and a simplified build process. Jekyll takes Markdown and HTML files and creates a complete static website based on your choice of layouts. Jekyll supports Markdown and Liquid, a templating language that loads dynamic content on your site. For more information, see Jekyll.

Windows 并未正式支持 Jekyll。 For more information, see "Jekyll on Windows" in the Jekyll documenation.

We recommend using Jekyll with GitHub 页面. If you prefer, you can use other static site generators or customize your own build process locally or on another server. 更多信息请参阅“关于 GitHub 页面”。

Configuring Jekyll in your GitHub 页面 site

You can configure most Jekyll settings, such as your site's theme and plugins, by editing your _config.yml file. For more information, see "Configuration" in the Jekyll documentation.

Some configuration settings cannot be changed for GitHub 页面 sites.

lsi: false
safe: true
source: [your repo's top level directory]
incremental: false
highlighter: rouge
gist:
  noscript: false
kramdown:
  math_engine: mathjax
  syntax_highlighter: rouge

By default, Jekyll doesn't build files or folders that:

If you want Jekyll to process any of these files, you can use the includes setting in your configuration file.

Front matter

To set variables and metadata, such as a title and layout, for a page or post on your site, you can add YAML front matter to the top of any Markdown or HTML file. For more information, see "Front Matter" in the Jekyll documentation.

You can add site.github to a post or page to add any repository references metadata to your site. For more information, see "Using site.github" in the Jekyll Metadata documentation.

Themes

You can add a Jekyll theme to your GitHub 页面 site to customize the look and feel of your site. For more information, see "Themes" in the Jekyll documentation.

You can add a supported theme to your site manually. For more information, see "Supported themes" on the GitHub 页面 site and "Adding a theme to your GitHub 页面 site using Jekyll."

You can override any of your theme's defaults by editing the theme's files. For more information, see your theme's documentation and "Overriding your theme's defaults" in the Jekyll documentation.

Plugins

You can download or create Jekyll plugins to extend the functionality of Jekyll for your site. For example, the jemoji plugin lets you use GitHub-flavored emoji in any page on your site the same way you would on GitHub. For more information, see "Plugins" in the Jekyll documentation.

GitHub 页面 uses plugins that are enabled by default and cannot be disabled:

You can enable additional plugins by adding the plugin's gem to the plugins setting in your _config.yml file. For more information, see "Configuration" in the Jekyll documentation. For a list of supported plugins, see "Dependency versions" on the GitHub 页面 site.

For usage information for a specific plugin, see the plugin's documentation.

Tip: You can make sure you're using the latest version of all plugins by keeping the GitHub 页面 gem updated. For more information, see "Testing your GitHub Pages site locally with Jekyll" and "Dependency versions" on the GitHub 页面 site.

GitHub 页面 cannot build sites using unsupported plugins. If you want to use unsupported plugins, generate your site locally and then push your site's static files to GitHub Enterprise.

语法突显

To make your site easier to read, code snippets are highlighted on GitHub 页面 sites the same way they're highlighted on GitHub Enterprise. For more information about syntax highlighting on GitHub Enterprise, see "Creating and highlighting code blocks."

By default, code blocks on your site will be highlighted by Jekyll. Jekyll uses the Rouge highlighter, which is compatible with Pygments. If you specify Pygments in your _config.yml file, Rouge will be used instead. Jekyll cannot use any other syntax highlighter, and you'll get a page build warning if you specify another syntax highlighter in your _config.yml file. For more information, see "About Jekyll build errors for GitHub 页面 sites."

If you want to use another highlighter, such as highlight.js, you must disable Jekyll's syntax highlighting by updating your project's _config.yml file.

kramdown:
  syntax_highlighter_opts:
    disable : true

If your theme doesn't include CSS for syntax highlighting, you can generate GitHub's syntax highlighting CSS and add it to your project's style.css file.

$ rougify style github > style.css

Building your site locally

Changes to your site are published automatically when the changes are merged into your site's publishing source. If you want to preview your changes first, you can make the changes locally instead of on GitHub Enterprise. Then, test your site locally. For more information, see "Testing your GitHub 页面 site locally with Jekyll."

问问别人

找不到要找的内容?

联系我们