Jekyll Cheatsheet
Learn everything Jekyll is capable of from an exhaustive list of variables, tags, and filters.
Collection variables Docs
The full path to the collections's source directory.
Input
{{ site.my_collection.directory }}
Output
/Users/mike/jekyll-project/_my_collection
An array of the collection's documents.
Input
{{ site.my_collection.docs.first.url }}
Output
/my_collection/item.html
An array of static files in the collection.
Input
{{ site.my_collection.files | size }}
Output
0
The name of your collection.
Input
{{ site.my_collection.label }}
Output
my_collection
Whether the collection's documents will be output as individual files.
Input
{{ site.my_collection.output }}
Output
true
The path to the document's source file relative to the site source.
Input
{{ site.collections.my_collection.relative_path }}
Output
_my_collection
Document variables Docs
Label of the containing collection.
Input
{{ site.my_collection.first.collection }}
Output
my_collection
The content of the collection item, rendered or un-rendered depending upon what Liquid is being processed and the item is.
Input
{{ site.my_collection.first.content }}
Output
Hello from my_collection.
The path to the document's source file relative to the site source.
Input
{{ site.my_collection.first.relative_path }}
Output
_my_collection/item.md
Global variables Docs
Liquid filters - array Docs
Append characters to a string.
Input
<!-- page.my_array is ['a', 'b', 'c'] -->
{{ page.my_array | array_to_sentence_string }}
{{ page.my_array | array_to_sentence_string: 'or' }}Output
a, b, and c
a, b, or cGet the first element of the passed in array.
Input
<!-- page.my_array is ['a', 'b', 'c'] -->
{{ page.my_array | first }}Output
a
Group an array's items by a given property.
Input
<!-- page.people is
- name: "John"
school: "Stanford"
- name: "Jane"
school: "Stanford"
- name: "Joe"
school: "Harvard"
-->
{{ page.people | group_by: "school" }}Output
{
"name"=>"Stanford",
"items"=>[{
"name"=>"John",
"school"=>"Stanford"
}, {
"name"=>"Jane",
"school"=>"Stanford"
}]
},
{
"name"=>"Harvard",
"items"=>[{
"name"=>"Joe",
"school"=>"Harvard"
}]
}Group an array's items using a Liquid expression.
Input
<!-- page.people is
- name: "John"
school: "Stanford"
year: 2016
- name: "Jane"
school: "Stanford"
year: 2017
- name: "Joe"
school: "Harvard"
year: 2015
-->
{{ page.people | group_by_exp: "item", "item.name | size" }}
{{ page.people | group_by_exp: "item", "item.year | modulo: 2" }}
{{ page.people | group_by_exp: "item", "item.school | replace: 'rd', 'ry' " }}Output
{"name"=>4, "items"=>[{"name"=>"John", "school"=>"Stanford", "year"=>2016}, {"name"=>"Jane", "school"=>"Stanford", "year"=>2017}], "size"=>2}{"name"=>3, "items"=>[{"name"=>"Joe", "school"=>"Harvard", "year"=>2015}], "size"=>1}
{"name"=>0, "items"=>[{"name"=>"John", "school"=>"Stanford", "year"=>2016}], "size"=>1}{"name"=>1, "items"=>[{"name"=>"Jane", "school"=>"Stanford", "year"=>2017}, {"name"=>"Joe", "school"=>"Harvard", "year"=>2015}], "size"=>2}
{"name"=>"Stanfory", "items"=>[{"name"=>"John", "school"=>"Stanford", "year"=>2016}, {"name"=>"Jane", "school"=>"Stanford", "year"=>2017}], "size"=>2}{"name"=>"Harvary", "items"=>[{"name"=>"Joe", "school"=>"Harvard", "year"=>2015}], "size"=>1}Joins an array with the specified character.
Input
<!-- page.my_array is ['a', 'b', 'c'] -->
{{ page.my_array | join: ', ' }}Output
a, b, c
Convert Hash or Array to JSON.
Input
<!-- page.my_array is ['a', 'b', 'c'] -->
{{ page.my_array | jsonify }}Output
["a","b","c"]
Get the last element of the passed in array.
Input
<!-- page.my_array is ['a', 'b', 'c'] -->
{{ page.my_array | last }}Output
c
Accepts an array element's attribute as a parameter and creates a string out of each array element's value.
Input
<!-- page.people is
- name: "John"
school: "Stanford"
- name: "Jane"
school: "Stanford"
- name: "Joe"
school: "Harvard"
-->
{{ page.people | map: "name" }}Output
JohnJaneJoe
Adds an object to a array.
Input
{% assign my_array = "a,b,c" | split:"," %}
{% assign my_array = my_array | push: 'd' %}
{{ my_array | array_to_sentence_string }}Output
a, b, c, and d
Return the size of an array or string.
Input
<!-- page.my_array is ['a', 'b', 'c'] -->
{{ page.my_array | size }}Output
3
Sorts an array.
Input
<!-- page.my_array is ['c', 'a', 'b'] -->
{{ page.my_array | sort }}Output
['a','b','c']
You can add a argument to sort on a property name:
Input
{{ page.posts | sort: 'author' }}
And also add a second argument to say whether the nils should be first or last:
Input
{{ page.posts | sort: 'author', 'last' }}
Removes duplicate elements from an array.
Input
<!-- page.my_array is ['cat', 'dog', 'mouse', 'cat'] -->
{{ page.my_array | uniq }}Output
'cat', 'dog', 'mouse'
Select all the objects in an array where the key has the given value.
Input
<!-- page.people is
- name: "John"
school: "Stanford"
- name: "Jane"
school: "Stanford"
- name: "Joe"
school: "Harvard"
-->
{{ page.people | where: "school", "Stanford" }}Output
{"name"=>"John", "school"=>"Stanford"}{"name"=>"Jane", "school"=>"Stanford"}
Select all the objects in an array where the expression is true.
Input
<!-- page.people is
- name: "John"
school: "Stanford"
year: 2016
- name: "Jane"
school: "Stanford"
year: 2017
- name: "Joe"
school: "Harvard"
year: 2015
-->
{{ page.people | where_exp: "item", "item.name contains 'Jo'" }}
{{ page.people | where_exp: "item", "item.year >= 2016" }}
{{ page.people | where_exp: "item", "item.school != "Stanford" }}Output
{"name"=>"John", "school"=>"Stanford", "year"=>2016}{"name"=>"Joe", "school"=>"Harvard", "year"=>2015}
{"name"=>"John", "school"=>"Stanford", "year"=>2016}{"name"=>"Jane", "school"=>"Stanford", "year"=>2017}
{"name"=>"Joe", "school"=>"Harvard", "year"=>2015}
Liquid filters - date Docs
Converts a date into another format.
Input
{{ site.time | date: "%a, %b %d, %y" }}
Output
Wed, Jan 27, 16
- %a - Abbreviated weekday (Sun)
- %A - Full weekday name (Sunday)
- %b - Abbreviated month name (Jan)
- %B - Full month name (January)
- %c - Preferred local date and time representation (Fri Jan 29 11:16:09 2016)
- %d - Day of the month, zero-padded (05)
- %-d - Day of the month (5)
- %D - Formats the date (29/01/16).
- %e - Day of the month (3).
- %F - Returns the date in ISO 8601 format (2016-01-29).
- %H - Hour of the day, 24-hour clock (07)
- %I - Hour of the day, 12-hour clock (04)
- %j - Day of the year (017)
- %k - Hour of the day, 24-hour clock (7)
- %m - Month of the year (04)
- %M - Minute of the hour (09)
- %p - Meridian indicator uppercase (AM)
- %P - Meridian indicator lowercase (pm)
- %r - 12-hour time (01:31:43 PM)
- %R - 24-hour time (18:09)
- %T - 24-hour time with seconds (18:09:13)
- %s - Number of seconds since 1970-01-01 00:00:00 UTC (1452355261)
- %S - Second of the minute (05)
- %U - Week number of the current year, starting with the first Sunday as the first day of the first week (03)
- %W - Week number of the current year, starting with the first Monday as the first day of the first week (09)
- %w - Day of the week. Sunday is 0 (4)
- %x - Preferred representation for the date (05/11/15)
- %X - Preferred representation for the time (17:15:31)
- %y - Year without a century (16)
- %Y - Year with century (2016)
- %Z - Time zone name (PST)
- %% - Literal % character
Convert a date to long format.
Input
{{ site.time | date_to_long_string }}
Output
01 January 2016
Convert a Date into RFC-822 format.
Input
{{ site.time | date_to_rfc822 }}
Output
Mon, 07 Nov 2008 13:07:54 -0800
Convert a date to short format.
Input
{{ site.time | date_to_string }}
Output
01 Jan 2016
Convert a Date into ISO 8601 format.
Input
{{ site.time | date_to_xmlschema }}
Output
2008-11-07T13:07:54-08:00
Liquid filters - integer Docs
Rounds a number up to the nearest whole number.
Input
{{ 1.2 | ceil }}
Output
2
Integer division.
Input
{{ 10 | divided_by:3 }}
Output
3
Rounds a number down to the nearest whole number.
Input
{{ 1.2 | floor }}
Output
1
Subtraction.
Input
{{ 4 | minus:1 }}
Output
3
Remainder.
Input
{{ 3 | modulo:2 }}
Output
1
Addition.
Input
{{ 4 | plus:1 }}
Output
5
Rounds a number to the nearest whole number.
Input
{{ 1.8 | round }}
Output
2
Integer multiplication.
Input
{{ 10 | times:3 }}
Output
30
Liquid filters - string Docs
Prepend the `baseurl` and `url` to the input.
Input
<!-- baseurl is set to "/mysite" in _config.yml -->
<!-- url is set to "http://example.com" in _config.yml -->
{{ '/images/dog.jpeg' | absolute_url }}Output
http://example.com/mysite/images/dog.jpeg
Append characters to a string.
Input
{{ 'jekyll' | append: '.jpg' }}
Output
jekyll.jpg
Capitalizes the first character.
Input
{{ "static site generator" | capitalize }}
Output
Static site generator
Escape a string for use in a URL.
Input
{{ "foo,bar;baz?" | cgi_escape }}
Output
foo%2Cbar%3Bbaz%3F
Set a fallback incase a value doesn't exist.
Input
{{ nil | default: "hello" }}
Output
hello
Converts a string to lowercase.
Input
{{ "STATIC Site generator" | downcase }}
Output
static site generator
Returns an escaped version of html.
Input
{{ "<p>Jekyll</p>" | escape }}
Output
&lt;p&gt;Jekyll&lt;/p&gt;
Removes whitespace characters from the beginning of a string.
Input
{{ ' I love Jekyll! ' | lstrip }}
Output
I love Jekyll!
Convert a Markdown-formatted string into HTML.
Input
{{ "Hello **Jekyll**" | markdownify }}
Output
Hello <strong>Jekyll</strong>
Count the number of words in a string.
Input
{{ "Hi Jekyll!" | number_of_words }}
Output
2
Prepend characters to a string.
Input
{{ 'Jekyll' | prepend: 'I love ' }}
Output
I love Jekyll
Prepend the `baseurl` value to the input.
Input
<!-- baseurl is set to "/mysite" in _config.yml -->
{{ '/images/dog.jpeg' | relative_url }}Output
/mysite/images/dog.jpeg
Removes any occurrence of a substring from a string.
Input
{{ 'I really really like Jekyll' | remove: 'really' }}
Output
I like Jekyll
Removes only the first occurrence of a substring from a string.
Input
{{ 'I really really like Jekyll' | remove_first: 'really' }}
Output
I really like Jekyll
Replaces any occurrence of a substring from a string.
Input
{{ 'I really really like Jekyll' | replace: 'really', 'truly' }}
Output
I truly truly like Jekyll
Replaces only the first occurrence of a substring from a string.
Input
{{ 'I really really like Jekyll' | replace_first: 'really', 'kinda' }}
Output
I kinda really like Jekyll
Removes whitespace characters from the end of a string.
Input
{{ ' I love Jekyll! ' | rstrip }}
Output
I love Jekyll!
Convert a Sass string into CSS output.
Input
// assigned to sass_code
body
color: #333
// ignored comment
background-color: yellow
p
/* fixed comment
color: green{{ sass_code | sassify }}
Output
body {
color: #333;
background-color: yellow;
}
body p {
/* fixed comment */
color: green;
}Convert a SCSS string into CSS output.
Input
// assigned to scss_code
body {
color: #333;
// ignored comment
background-color: yellow;
p {
/* fixed comment */
color: green;
}
}{{ scss_code | sassify }}
Output
body {
color: #333;
background-color: yellow;
}
body p {
/* fixed comment */
color: green;
}Return the size of a string.
Input
<!-- page.my_string is jekyll -->
{{ page.my_string | size }}Output
6
returns a substring, starting at the specified index.
Input
{{ "hello" | slice: 0 }}
{{ "hello" | slice: 1 }}
{{ "hello" | slice: 1, 3 }}
{{ "hello" | slice: -2 }}
{{ "hello" | slice: -3, 2 }}Output
h
e
ell
l
llConvert a string into a lowercase URL slug.
Input
{{ "The _config.yml file" | slugify }}
Output
the-config-yml-file
The slugify filter accepts an option, each specifying what to filter. The default is default. They are as follows (with what they filter):
none
: no charactersraw
: spacesdefault
: spaces and non-alphanumeric characterspretty
: spaces and non-alphanumeric characters except for._~!$&'()+,;=@
Convert quotes into smart quotes with SmartyPants
Input
{{ 'Use "Jekyll" --- the static generator...' | smartify }}
Output
Use “Jekyll” — the static generator…
Divide a string into an array.
Input
{{ "a~b" | split:"~" }}
Output
['a', 'b']
Removes whitespace characters from around a string.
Input
{{ ' I love Jekyll! ' | strip }}
Output
I love Jekyll!
Strip all html tags from the input string.
Input
{{ "<p>Jekyll is cool</p>" | strip_html }}
Output
Jekyll is cool
Strip all new line characters from the input string.
Input
{{ "Hello
there" | strip_newlines }}Output
Hello there
Truncate a string down to x characters.
Input
{{ "I love Jekyll" | truncate: 12 }}
{{ "I love Jekyll" | truncate: 12, " etc." }}Output
I love Je...
I love etc.Truncate string down to x words.
Input
{{ "I love Jekyll" | truncatewords: 2 }}
Output
I love...
Converts a string to uppercase.
Input
{{ "static site generator" | upcase }}
Output
STATIC SITE GENERATOR
URI escape a string.
Input
{{ "foo, bar \baz?" | uri_escape }}
Output
foo,%20bar%20%5Cbaz?
Encodes any characters unsafe for a URL.
Input
{{ "john@example.com" | url_encode }}
Output
john%40example.com
Select all the objects in an array where the key has the given value.
Input
{{ "<p>Hi Jekyll</p>"| xml_escape }}
Output
&lt;p&gt;Hi Jekyll&lt;/p&gt;
Liquid for loops Docs
Condition when there are no items in the array.
Input
<!-- page.my_array is [] -->
{% for item in page.my_array %}
{{ item }}
{% else %}
There are no items!
{% endfor %}Output
There are no items!
Returns whether it's the first iteration.
Input
<!-- page.my_array is [1, 2, 3] -->
{% for item in page.my_array %}
{% if forloop.first %}
First!
{% else %}
Not first
{% endif %}
{% endfor %}Output
First! Not first Not first
index of the current iteration.
Input
<!-- page.my_array is ['a', 'b', 'c'] -->
{% for item in page.my_array %}
{{ forloop.index }}
{% endfor %}Output
1 2 3
index of the current iteration (zero based).
Input
<!-- page.my_array is ['a', 'b', 'c'] -->
{% for item in page.my_array %}
{{ forloop.index0 }}
{% endfor %}Output
0 1 2
Returns whether it's the last iteration.
Input
<!-- page.my_array is [1, 2, 3] -->
{% for item in page.my_array %}
{% if forloop.last %}
Last!
{% else %}
Not last
{% endif %}
{% endfor %}Output
Not last Not last Last!
Length of the entire loop.
Input
<!-- page.my_array is ['a', 'b', 'c'] -->
{% for item in page.my_array %}
{{ forloop.length }}
{% endfor %}Output
3 3 3
Restrict how many items are looped through.
Input
<!-- page.my_array is [1, 2, 3, 4, 5] -->
{% for item in page.my_array limit: 2 %}
{{ item }}
{% endfor %}Output
1 2
Start looping from the nth item.
Input
<!-- page.my_array is [1, 2, 3, 4, 5] -->
{% for item in page.my_array offset: 2 %}
{{ item }}
{% endfor %}Output
3 4 5
Reverses the order.
Input
<!-- page.my_array is [1, 2, 3, 4, 5] -->
{% for item in page.my_array reversed %}
{{ item }}
{% endfor %}Output
5 4 3 2 1
Outputs the number of iterations left.
Input
<!-- page.my_array is ['a', 'b', 'c'] -->
{% for item in page.my_array %}
{{ forloop.rindex }}
{% endfor %}Output
3 2 1
Outputs the number of iterations left (zero based).
Input
<!-- page.my_array is ['a', 'b', 'c'] -->
{% for item in page.my_array %}
{{ forloop.rindex0 }}
{% endfor %}Output
2 1 0
Liquid tags - control flow Docs
Creates a switch statement to compare a variable with different values. `case` initializes the switch statement, and `when` compares its values.
Input
<!-- page.name is set to "home" -->
{% case page.name %}
{% when 'home' %}
Home Page
{% when 'about' %}
About Page
{% else %}
Contact Page
{% endcase %}Output
Home Page
Adds more conditions to an `if` or `unless` block.
Input
<!-- page.name is set to "contact" -->
{% if page.name == 'about' %}
About Page
{% elsif page.name == 'contact' %}
Contact Page
{% else %}
Other Page
{% endif %}Output
Contact Page
Executes a block of code only if a certain condition is met.
Input
<!-- page.name is set to "about" -->
{% if page.name == 'about' %}
About Page
{% endif %}Output
About Page
Operators used in logic statements.
- == equal
- != not equal
- > bigger than
- < less than
- >= bigger or equal
- <= less or equal
- or this or that
- and must be this and that
- contains includes the substring if used on a string, or element if used on an array
Similar to `if`, but executes a block of code only if a certain condition is **not** met.
Input
<!-- page.name is set to "about" -->
{% unless page.name == "contact" %}
It's not the contact page
{% endunless %}Output
It's not the contact page
Which is the same as doing:
{% if page.name != "contact" %}
It's not the contact page
{% endif %}
Liquid tags - iteration Docs
Causes the loop to stop iterating.
Input
{% for i in (1..5) %}
{% if i == 3 %}
{% break %}
{% else %}
{{ i }}
{% endif %}
{% endfor %}Output
1 2
Causes the loop to skip the current iteration.
Input
{% for i in (1..5) %}
{% if i == 3 %}
{% continue %}
{% else %}
{{ i }}
{% endif %}
{% endfor %}Output
1 2 4 5
Loops through a group of strings and outputs them in the order that they were passed as parameters.
cycle
must be used within a for loop block.Input
{% for i in (1..5) %}
{% cycle 'red', 'blue', 'yellow' %}
{% endfor %}Output
red blue yellow red blue
Creates a new variable and every time it's called the value decreases by 1, with the initial value being -1.
Input
{% decrement my_variable %}
{% decrement my_variable %}
{% decrement my_variable %}Output
-1
-2
-3Like
increment
, variables declared inside decrement are independent from variables created through assign or capture.Repeatedly executes a block of code.
Input
{% for page in site.pages %}
{{ page.title }}
{% endfor %}Output
index
about
contactCreates a new variable and every time it's called the value increases by 1, with the initial value being 0.
Input
{% increment my_variable %}
{% increment my_variable %}
{% increment my_variable %}Output
0
1
2Variables created through the
increment
tag are independent from variables created throughassign
orcapture
.In the example below,
my_var
is created throughassign
. Theincrement
tag is then used several times on a variable with the same name. However, note that theincrement
tag does not affect the value ofmy_var
that was created throughassign
.Input
{% assign my_var = 15 %}
{% increment var %}
{% increment var %}
{% increment var %}
{{ my_var }}Output
0
1
2
15
Liquid tags - other Docs
Don't output the contained text.
Input
My name is {% comment %}Mr{% endcomment %} Jekyll
Output
My name is Jekyll
Code snippet highlighting.
Input
{% highlight ruby %}
def foo
puts 'foo'
end
{% endhighlight %}Output
<div class="highlight">
<pre><code class="language-ruby" data-lang="ruby"><span class="k">def</span> <span class="nf">foo</span>
<span class="nb">puts</span> <span class="s1">'foo'</span>
<span class="k">end</span></code></pre></div>Inserts a file from the `_includes` directory.
Input
<h1>My site</h1>
{% include nav.html %}Output
<h1>My Site</h1>
<ul class="nav">
<li><a href="/">Home</a></li>
<li><a href="/about/">About</a></li>
<li><a href="/contact/">Contact</a></li>
</ul>Includes a file relative to the current file.
Input
<h1>My site</h1>
{% include_relative about.html %}Output
<h1>My Site</h1>
<h1>About</h1>Generate the correct permalink URL for the path you specify.
Input
{% link _collection/my-document.md %}
{% link _posts/2017-03-15-my-post.md %}
{% link blog/index.html %}
{% link assets/document.pdf %}Output
/my_collection/custom-permalink/my-document/
/blog/my-post/
/blog/
/assets/document.pdfGenerate the correct permalink URL for a post.
Input
{% post_url 2010-07-21-name-of-post %}
Output
/news/2010/07/21/name-of-post/
No liquid will be parsed in within these tags.
Input
{{ l_bracket}}% raw %{{ r_bracket }}
{% raw %}{{ page.title }}
{% endraw %}Output
{{ page.title }}
Liquid tags - variable Docs
Create a new variable.
Input
{% assign my_variable = false %}
{% if my_variable != true %}
Hi there!
{% endif %}Output
Hi there!
Captures the string inside of the opening and closing tags and assigns it to a variable.
Input
{% capture my_variable %}
Captured text.
{% endcapture %}
{{ my_variable }}Output
Captured text.
Markdown Docs
Input
> Blockquotes are very handy in email to emulate reply text.
> This line is part of the same quote.Output
<blockquote>
<p>Blockquotes are very handy in email to emulate reply text.
This line is part of the same quote.</p>
</blockquote>Input
```
def what?
42
end
```
{: .language-ruby}Output
<pre>
<code class="language-ruby">
def what?
42
end
</code>
</pre>Input
HTML
: Hypertext Markup Language, a standardized system for tagging text files.
CSS
: Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup languageOutput
<dl>
<dt>HTML</dt>
<dd>Hypertext Markup Language, a standardized system for tagging text files.</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language</dd>
</dl>Input
# H1
## H2
### H3
#### H4
##### H5
###### H6Output
<h1 id="h1">H1</h1>
<h2 id="h2">H2</h2>
<h3 id="h3">H3</h3>
<h4 id="h4">H4</h4>
<h5 id="h5">H5</h5>
<h6 id="h6">H6</h6>Input
---
Output
<hr />
Input
1. First item
2. Second item
3. Third item
* First item
* Second item
* Third itemOutput
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>Input
A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines
Output
<p>A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines</p>
Input
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |Output
<table>
<thead>
<tr>
<th>Tables</th>
<th style="text-align: center">Are</th>
<th style="text-align: right">Cool</th>
</tr>
</thead>
<tbody>
<tr>
<td>col 3 is</td>
<td style="text-align: center">right-aligned</td>
<td style="text-align: right">$1600</td>
</tr>
<tr>
<td>col 2 is</td>
<td style="text-align: center">centered</td>
<td style="text-align: right">$12</td>
</tr>
<tr>
<td>zebra stripes</td>
<td style="text-align: center">are neat</td>
<td style="text-align: right">$1</td>
</tr>
</tbody>
</table>Input
**strong** text
_emphasis_ text
`inline` code
[link](http://jekyllrb.com) text
![Alt tag](/path/to/image.jpg)Output
<p><strong>strong</strong> text</p>
<p><em>emphasis</em> text</p>
<p><code>inline</code> code</p>
<p><a href="http://jekyllrb.com">link</a> text</p>
<p><img src="/path/to/image.jpg" alt="Alt tag" /></p>
Page variables Docs
Post variables Docs
The list of categories to which this post belongs.
Input
<!-- tags is set to
categories:
- news
-->
{{ page.categories | array_to_sentence_string }}Output
news
The content of the post, rendered or un-rendered depending upon what Liquid is being processed and what `post` is.
Input
{{ page.content }}
Output
Hello World!
The date assigned to the Post.
Input
{{ page.date }}
Output
2016-02-02 00:00:00 -0800
The un-rendered excerpt of the Post.
Input
{{ page.excerpt }}
Output
Hello World!
An identifier unique to the Post.
Input
{{ page.id }}
Output
/2015/10/11/hello-world
The next post relative to the position of the current post in `site.posts`. Returns `nil` for the last entry.
Input
{{ page.next.title }}
Output
/2016/01/02/hello-world.html
The previous post relative to the position of the current post in `site.posts`. Returns `nil` for the first entry.
Input
{{ page.previous.title }}
Output
/2016/01/02/im-fleeting.html
The list of tags to which this post belongs.
Input
<!-- tags is set to
tags:
- HTML
- CSS
-->
{{ page.tags | array_to_sentence_string }}Output
HTML and CSS
The title of the post.
Input
{{ page.title }}
Output
Hello World
Site variables Docs
The list of all Posts in a category.
Input
{% for p in site.categories.news %}
{{ p.url }}
{% endfor %}Output
/2016/01/03/goodbye-world.html
/2016/01/01/hello-world.htmlA list of all the collections.
Input
{{ site.collections | size }}
Output
1
All the variables set via the command line and your `_config.yml` are available through `site`.
Input
<!-- url is set to http://mysite.com in the configuration file -->
{{ site.url }}Output
http://mysite.com
A list containing the data loaded from the YAML, JSON and CSV files located in the _data directory.
Input
{{ site.data.nba_players.first.name }}
Output
Michael Jordan
A list of all the documents in every collection.
Input
{{ site.documents | size }}
Output
19
A subset of `site.pages` listing those which end in `.html`
Input
{% for p in site.html_pages %}
{{ p.path }}
{% endfor %}Output
about.html
contact.html
index.htmlA list of all Pages.
Input
{% for p in site.pages %}
{{ p.path }}
{% endfor %}Output
about.html
contact.html
index.html
site-map.xmlA reverse chronological list of all Posts.
Input
{% for p in site.posts %}
{{ p.url }}
{% endfor %}Output
/2016/01/03/goodbye-world.html
/2016/01/02/im-fleeting.html
/2016/01/01/hello-world.htmlIf 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.
Input
<!-- run on /_posts/2016-01-01-hello-world.md -->
{% for p in site.related_posts %}
{{ p.title }}
{% endfor %}Output
Goodbye World
Im FleetingA list of all static files (i.e. files not processed by Jekyll's converters or the Liquid renderer).
Input
{% for file in site.static_files %}
{{ file.path }}
{% endfor %}Output
/css/style.css
/js/my-script.jsThe list of all Posts with a particular tag.
Input
{% for p in site.tags.sad %}
{{ p.url }}
{% endfor %}Output
/2016/01/03/goodbye-world.html
/2016/01/02/im-fleeting.htmlThe current time (when you run the jekyll command).
Input
{{ site.time }}
Output
2016-01-28 08:32:19 -0800
Static file variables Docs
Yaml Docs
Input
# Nest hash
my_hash:
subkey:
subsubkey1: 5
subsubkey2: 6
another:
somethingelse: 'Important!'
# Hash of hashes
my_hash: {nr1: 5, nr2: 6}Input
# sequence
array:
- 132
- 2.434
- 'abc'
# sqeuence of sequences
my_array:
- [1, 2, 3]
- [4, 5, 6]Input
a: 1
b: 1.234
c: 'abc'
d: "abc"
e: abc
f: false # boolean type
g: 2015-04-05 # date type
# Enforcing strings
h: !str 2015-04-05