變量
Jekyll 遍歷你的站點并尋找需要處理的文件。任何文件只要帶有 front matter 就會被處理。對于每一個需要處理的 文件,Jekyll 通過 Liquid 為其提供各種數(shù)據(jù)。 以下是所有可用數(shù)據(jù)的完整列表。
全局變量
| Variable | Description |
|---|---|
|
Site wide information + configuration settings from |
|
Page specific information + the front matter. Custom variables set via the front matter will be available here. See below for details. |
|
Layout specific information + the front matter. Custom variables set via front matter in layouts will be available here. |
|
In layout files, the rendered content of the Post or Page being wrapped. Not defined in Post or Page files. |
|
When the |
站點(Site)變量
| Variable | Description |
|---|---|
|
The current time (when you run the |
|
A list of all Pages. |
|
A reverse chronological list of all Posts. |
|
If the page being processed is a Post, this contains a list of up to ten related Posts. By default, these are the ten most recent posts. For high quality but slow to compute results, run the |
|
A list of all static files (i.e. files not processed by Jekyll's converters or the Liquid renderer). Each file has five properties: |
|
A subset of |
|
A subset of |
|
A list of all the collections (including posts). |
|
A list containing the data loaded from the YAML files located in the |
|
A list of all the documents in every collection. |
|
The list of all Posts in category |
|
The list of all Posts with tag |
|
Contains the url of your site as it is configured in the |
|
All the variables set via the command line and your |
頁面(Page)變量
| Variable | Description |
|---|---|
|
The content of the Page, rendered or un-rendered depending upon what Liquid is being processed and what |
|
The title of the Page. |
|
The un-rendered excerpt of a document. |
|
The URL of the Post without the domain, but with a leading slash, e.g. |
|
The Date assigned to the Post. This can be overridden in a Post’s front matter by specifying a new date/time in the format |
|
An identifier unique to a document in a Collection or a Post (useful in RSS feeds). e.g. |
|
The list of categories to which this post belongs. Categories are derived from the directory structure above the |
|
The label of the collection to which this document belongs. e.g. |
|
The list of tags to which this post belongs. These can be specified in the front matter. |
|
The path between the source directory and the file of the post or page, e.g. |
|
The filename of the post or page, e.g. |
|
The path to the raw post or page. Example usage: Linking back to the page or post’s source on GitHub. This can be overridden in the front matter. |
|
The next post relative to the position of the current post in |
|
The previous post relative to the position of the current post in |
ProTip?: 使用自定義的 Front Matter
你自己定義的任何 front matter 都可以在
頁面(page) 中直接引用。例如,如果你定義了 custom_css: true
在頁面的 front matter 中,那么,可以通過 page.custom_css 訪問。
如果你在布局文件(layout)中定義了 front matter,那么可以通過 layout 變量訪問。
例如,如果你在布局文件(layout)的 front matter 中定義了 class: full_page,
那么該值可以在布局文件及其父文件中通過 layout.class 訪問。
分頁器
| Variable | Description |
|---|---|
|
The number of the current page |
|
Number of posts per page |
|
Posts available for the current page |
|
Total number of posts |
|
Total number of pages |
|
The number of the previous page, or |
|
The path to the previous page, or |
|
The number of the next page, or |
|
The path to the next page, or |
分頁器變量的可用范圍
這些只在 index 文件中可以使用,不過,index 文件可以位于子目錄中,
例如 /blog/index.html。