目录结构

一个基本的 Jekyll 站点通常是这样的:

.
├── _config.yml
├── _data
│   └── members.yml
├── _drafts
│   ├── begin-with-the-crazy-ideas.md
│   └── on-simplicity-in-technology.md
├── _includes
│   ├── footer.html
│   └── header.html
├── _layouts
│   ├── default.html
│   └── post.html
├── _posts
│   ├── 2007-10-29-why-every-programmer-should-play-nethack.md
│   └── 2009-04-26-barcamp-boston-4-roundup.md
├── _sass
│   ├── _base.scss
│   └── _layout.scss
├── _site
├── .jekyll-cache
│   └── Jekyll
│       └── Cache
│           └── [...]
├── .jekyll-metadata
└── index.html # 也可以是带 front matter 的 'index.md' 文件
使用基于 gem 格式的主题的 Jekyll 站点的目录结构

3.2 版本开始,通过 jekyll new 命令创建的站点使用 基于 gem 格式的主题 来定义站点的外观。 最终生成的站点的默认目录结构更加简化: 默认情况下,只有 _layouts_includes_sass 目录存在于基于 gem 格式的主题中。


minima 是当前的默认主题,并且执行 bundle info minima 命令将显示 minima 主题所包含的文件在当前计算机上的存储位置。

每个文件的功能:

文件 / 目录 描述

_config.yml

存储的是 配置 信息。其中许多 参数是可以在命令行中指定的,但是 在此文件中进行设置会更容易些,并且你不必记住它们。

_drafts

草稿(Drafts)是未发布的文章(posts)。这些文章的文件名中没有包含 日期: title.MARKUP。了解如何 使用草稿功能

_includes

These are the partials that can be mixed and matched by your layouts and posts to facilitate reuse. The liquid tag {% include file.ext %} can be used to include the partial in _includes/file.ext.

_layouts

这里存放的是These are the templates that wrap posts. Layouts are chosen on a post-by-post basis in the front matter, which is described in the next section. The liquid tag {{ content }} is used to inject content into the web page.

_posts

Your dynamic content, so to speak. The naming convention of these files is important, and must follow the format: YEAR-MONTH-DAY-title.MARKUP. The permalinks can be customized for each post, but the date and markup language are determined solely by the file name.

_data

格式化的站点数据应当放在此目录下。Jekyll 将自动加载此目录下的所有数据文件(支持 .yml.yaml.json.csv.tsv 格式和扩展名), 然后就可以通过 `site.data` 来访问了。假定在 此目录下有一个文件名为 members.yml 的文件,那么你可以通过 site.data.members 变量来访问该文件中的内容。

_sass

These are sass partials that can be imported into your main.scss which will then be processed into a single stylesheet main.css that defines the styles to be used by your site. Learn how to work with assets.

_site

在 Jekyll 转换完所有的文件之后,将在此目录下放置生成的站点(默认情况下)。 最好将此目录添加到 .gitignore 文件中。

.jekyll-cache

Keeps a copy of the generated pages and markup (e.g.: markdown) for faster serving. Created when using e.g.: jekyll serve. Can be disabled with an option and/or flag. This directory will not be included in the generated site. It’s probably a good idea to add this to your .gitignore file.

.jekyll-metadata

This helps Jekyll keep track of which files have not been modified since the site was last built, and which files will need to be regenerated on the next build. Only created when using incremental regeneration (e.g.: with jekyll serve -I). This file will not be included in the generated site. It’s probably a good idea to add this to your .gitignore file.

index.html or index.md and other HTML, Markdown files

Provided that the file has a front matter section, it will be transformed by Jekyll. The same will happen for any .html, .markdown, .md, or .textile file in your site’s root directory or directories not listed above.

其它文件/目录

Except for the special cases listed above, every other directory and file—such as css and images folders, favicon.ico files, and so forth—will be copied verbatim to the generated site. There are plenty of sites already using Jekyll if you’re curious to see how they’re laid out.

Every file or directory beginning with the following characters: ., _ , # or ~ in the source directory will not be included in the destination folder. Such paths will have to be explicitly specified via the config file in the include directive to make sure they’re copied over:

include:
 - _pages
 - .htaccess