# Jekyll（软件）

**Jekyll** 是一个用 Ruby 编写的静态网站生成器，它将纯文本模板、Markdown 和配置转换为完整的静态网站，无需数据库或服务器端应用。它由 GitHub 联合创始人[汤姆·普雷斯顿-沃纳](https://www.edgepedia.org/zh/tom-preston-werner)（Tom Preston-Werner）创建，于2008年11月17日发布，当时被介绍为一个“简单的、面向博客的静态网站生成器”，它让模板目录经过 Textile 和 Liquid 转换器处理，输出适合用 Apache 或任何 Web 服务器托管的网站。<sup>[1](https://tom.preston-werner.com/2008/11/17/blogging-like-a-hacker)</sup><sup> • </sup><sup>[2](https://w3techs.com/technologies/breakdown/cm-jekyll/markup_language)</sup> Jekyll 最为人所知的身份是 GitHub Pages 背后的引擎，当源文件被推送到仓库时，GitHub Pages 会自动生成网站。<sup>[3](https://jekyllrb.com/docs/github-pages/)</sup>

| 关键事实 | 详情 |
|---|---|
| 是什么 | Ruby 静态网站生成器，将标记转换为可部署的 HTML，无需数据库<sup>[4](https://zairalabs.ai/guide/compare/eleventy-11ty-vs-jekyll/)</sup> |
| 创建时间 | 由汤姆·普雷斯顿-沃纳于2008年11月17日发布<sup>[1](https://tom.preston-werner.com/2008/11/17/blogging-like-a-hacker)</sup> |
| 模板 | Liquid 模板语言；YAML 前置元数据设置 layout、title 等变量<sup>[1](https://tom.preston-werner.com/2008/11/17/blogging-like-a-hacker)</sup><sup> • </sup><sup>[5](https://jekyllrb.com/docs/frontmatter/)</sup> |
| GitHub Pages | 内置支持；GitHub Pages 幕后由 Jekyll 驱动<sup>[3](https://jekyllrb.com/docs/github-pages/)</sup> |
| 最新版本 | v4.4.1，发布于2025年1月29日<sup>[6](https://rubygems.org/gems/jekyll/versions/4.4.1?locale=en)</sup> |
| 构建速度 | 10,000+ 页面的网站约需12秒，相比之下 Hugo 为1.5秒，Eleventy 为6秒<sup>[7](https://dasroot.net/posts/2026/03/hugo-vs-jekyll-vs-eleventy-static-site-generators/)</sup> |
| 使用情况 | 在 W3Techs 识别出内容管理系统的所有网站中占0.1%；在2024年 Web Almanac 中，可检测到静态网站生成器的预渲染网站中有9%使用 Jekyll<sup>[2](https://w3techs.com/technologies/breakdown/cm-jekyll/markup_language)</sup><sup> • </sup><sup>[8](https://cdn.httparchive.org/v1/static/almanac/ebooks/web_almanac_2024_en.pdf)</sup> |

## 起源

普雷斯顿-沃纳编写 Jekyll 是出于对 [WordPress](https://www.edgepedia.org/zh/wordpress) 和 Mephisto 等复杂博客引擎的不满。他希望自己的文章存储在 Git 仓库中，通过部署脚本或提交后钩子发布，并且更倾向于静态网站，而非需要持续维护的动态网站。他自己的博客成为第一个 Jekyll 网站，该项目作为一个年轻工具发布，只包含作者所需的功能，并邀请其他人 fork 并添加功能。<sup>[1](https://tom.preston-werner.com/2008/11/17/blogging-like-a-hacker)</sup>

该项目由一个志愿者核心团队维护，以 [MIT 许可证](https://www.edgepedia.org/zh/mit-license)发布。<sup>[9](https://jekyllrb.com/docs/rendering-process/)</sup><sup> • </sup><sup>[10](https://gautamkhorana.com/static-site-generators/compare/eleventy-vs-jekyll/)</sup>

## 构建流程

一次 Jekyll 构建会话按顺序经过若干独立阶段：设置插件、读取源文件、运行生成器、渲染模板，以及将文件写入磁盘。<sup>[9](https://jekyllrb.com/docs/rendering-process/)</sup>

**前置元数据。** 任何以 YAML 块开头、且该块由上下两行各含三个短横线的分隔行界定的文件，都会被 Jekyll 作为特殊文件处理。前置元数据可以设置预定义变量（如 `layout` 和 `title`）或自定义变量，这些变量可通过文件及其使用的任何布局或包含文件中的 Liquid 标签访问。甚至一个空的前置元数据块也足以让 Jekyll 处理该文件。<sup>[5](https://jekyllrb.com/docs/frontmatter/)</sup>

**渲染阶段。** 渲染阶段分为三个可选阶段，按顺序应用。首先，解释文件中的 Liquid 表达式，默认只做浅层处理，因此输出中的 Liquid 不会被再次求值，前置元数据中的 Liquid 也保持原样。其次，运行映射到文件扩展名的转换器，将 Markdown 转换为 HTML、Sass 或 Scss 转换为 CSS、[CoffeeScript](https://www.edgepedia.org/zh/coffeescript) 转换为 [JavaScript](https://www.edgepedia.org/zh/javascript)；`.html` 文件中的 Markdown 或 Sass 保持不变。第三，将输出放入布局中，布局可以相互嵌套，转换后的输出构成核心，布局依次围绕它渲染。<sup>[9](https://jekyllrb.com/docs/rendering-process/)</sup>

**内容类型。** 文章存放在 `_posts` 目录中，遵循 `YEAR-MONTH-DAY-title.MARKUP` 命名约定，文件名中的日期用于构造 URL。集合（Collections）将不必按日期排序的相关内容分组，例如团队成员或文档章节；集合在 `_config.yml` 中声明，其文档存放在 `_*collection_name*` 文件夹中，只有当集合设置 `output: true` 时，文档才会写入输出。放置在 `_data` 目录中的 YAML、JSON、CSV 或 TSV 格式的数据文件会被自动加载，并可通过 `site.data` 访问。<sup>[11](https://jekyllrb.com/docs/structure/)</sup><sup> • </sup><sup>[12](https://jekyllrb.com/docs/collections/)</sup><sup> • </sup><sup>[13](https://jekyllrb.com/docs/datafiles/)</sup>

## GitHub Pages

Jekyll 最紧密的集成是与 GitHub Pages 的集成，后者是面向用户、组织和仓库的免费托管服务，域名为 GitHub 的 `github.io` 或自定义域名。GitHub Pages 幕后由 Jekyll 驱动，当源文件被推送时，网站会自动重新生成。没有前置元数据的文件被视为静态资源，因此纯 HTML 内容无需额外设置即可使用。<sup>[3](https://jekyllrb.com/docs/github-pages/)</sup>

这种集成存在限制。出于安全原因，所有 GitHub Pages 网站都使用 `--safe` 选项生成，该选项禁用白名单之外的插件；不支持的插件需要在本地构建网站并推送生成的文件，或使用 [GitHub Actions](https://www.edgepedia.org/zh/github-actions) 以完全控制的方式构建和部署。<sup>[14](https://jekyllrb.com/docs/plugins/installation/)</sup> GitHub Pages 默认启用一组无法禁用的插件，包括 `jekyll-coffeescript`、`jekyll-gist`、`jekyll-github-metadata`、`jekyll-paginate` 和 `jekyll-relative-links`，并且代码块使用与 Pygments 兼容的 Rouge 高亮器。<sup>[15](https://docs.github.com/articles/redirects-on-github-pages)</sup> 据 GitHub 称，`github-pages` gem 对某些工作流仍然有效，但对于部署和自动化 Pages 网站，平台现在推荐使用 GitHub Actions。<sup>[15](https://docs.github.com/articles/redirects-on-github-pages)</sup>

## 插件与主题

插件可以从 `_plugins` 目录加载、在 `_config.yml` 中列出，或通过 Bundler 用 Gemfile 管理。特殊 `:jekyll_plugins` Gemfile 组中的 gem 会在任何 Jekyll 进程开始时加载，无论 `--safe` 标志或配置条目如何。这三种途径可以在同一网站中同时使用。<sup>[14](https://jekyllrb.com/docs/plugins/installation/)</sup>

主题打包了网站可以使用的布局和包含文件，无需复制其文件。当页面设置 `layout: page` 时，Jekyll 首先查找网站的 `_layouts` 文件夹，找不到时再使用主题的版本，主题的任何默认值都可以通过编辑主题文件来覆盖。在 GitHub Pages 上，仅支持部分基于 gem 的主题。<sup>[16](https://jekyllrb.com/docs/themes/)</sup>

## 使用情况与在生成器中的地位

Jekyll 的使用范围不大，但一直有人使用。据 W3Techs 2026年6月的调查，在其识别出内容管理系统的所有网站中，Jekyll 占0.1%。<sup>[2](https://w3techs.com/technologies/breakdown/cm-jekyll/markup_language)</sup> 基于 HTTP Archive 数据集的2024年 Web Almanac 发现，在可检测到静态网站生成器的预渲染网站中，Jekyll 占9%，落后于 Hugo 的18%和 Next.js 的13%，领先于 Astro、Docusaurus 和 Gatsby 各3%。<sup>[8](https://cdn.httparchive.org/v1/static/almanac/ebooks/web_almanac_2024_en.pdf)</sup>

与其主要替代品相比，Jekyll 的特点是稳定性而非速度。在2026年一项针对10,000+ 页面网站的生成器比较中，Jekyll 构建约需12秒，而 Hugo（无运行时依赖的 Go 编译二进制文件）为1.5秒，[Eleventy](https://www.edgepedia.org/zh/eleventy)（基于 JavaScript 的生成器）为6秒；同一比较将 Jekyll 的插件生态系统评为丰富，学习曲线评为低，并认为它最适合中小型博客。<sup>[7](https://dasroot.net/posts/2026/03/hugo-vs-jekyll-vs-eleventy-static-site-generators/)</sup> 一篇并列评测将 Jekyll 描述为静态网站生成器中的“元老”，拥有约49.2k GitHub 星标、MIT 许可证，开发节奏成熟而非活跃演进，并指出 Jekyll 仍是 GitHub Pages 的默认选项，而 Eleventy 需要 GitHub Actions 工作流。<sup>[10](https://gautamkhorana.com/static-site-generators/compare/eleventy-vs-jekyll/)</sup> 2026年它的实际定位是：没有迁移理由的现有 Jekyll 网站、GitHub Pages 项目，以及文章数量较少的个人博客。<sup>[10](https://gautamkhorana.com/static-site-generators/compare/eleventy-vs-jekyll/)</sup>

## References

1. [Tom Preston-Werner (2008). Blogging Like a Hacker](https://tom.preston-werner.com/2008/11/17/blogging-like-a-hacker)
2. [Usage of Jekyll broken down by markup languages, W3Techs](https://w3techs.com/technologies/breakdown/cm-jekyll/markup_language)
3. [GitHub Pages, Jekyll documentation](https://jekyllrb.com/docs/github-pages/)
4. [Eleventy (11ty) vs Jekyll: Documentation Comparison, Zaira Labs](https://zairalabs.ai/guide/compare/eleventy-11ty-vs-jekyll/)
5. [Front Matter, Jekyll documentation](https://jekyllrb.com/docs/frontmatter/)
6. [jekyll 4.4.1, RubyGems.org](https://rubygems.org/gems/jekyll/versions/4.4.1?locale=en)
7. [Hugo vs Jekyll vs Eleventy: Static Site Generators for Blogs, Dasroot](https://dasroot.net/posts/2026/03/hugo-vs-jekyll-vs-eleventy-static-site-generators/)
8. [The 2024 Web Almanac by HTTP Archive, Jamstack chapter](https://cdn.httparchive.org/v1/static/almanac/ebooks/web_almanac_2024_en.pdf)
9. [Rendering Process, Jekyll documentation](https://jekyllrb.com/docs/rendering-process/)
10. [Eleventy (11ty) vs Jekyll, which one wins for your brief, in 2026](https://gautamkhorana.com/static-site-generators/compare/eleventy-vs-jekyll/)
11. [Directory Structure, Jekyll documentation](https://jekyllrb.com/docs/structure/)
12. [Collections, Jekyll documentation](https://jekyllrb.com/docs/collections/)
13. [Data Files, Jekyll documentation](https://jekyllrb.com/docs/datafiles/)
14. [Plugins, Jekyll documentation](https://jekyllrb.com/docs/plugins/installation/)
15. [About GitHub Pages and Jekyll, GitHub Docs](https://docs.github.com/articles/redirects-on-github-pages)
16. [Themes, Jekyll documentation](https://jekyllrb.com/docs/themes/)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Named software products and platforms › Web servers and content platforms

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/jekyll-software

English original: https://www.edgepedia.org/jekyll-software
