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 Direct link to this section
{{ site.my_collection.directory }}
Output Direct link to this section
/Users/mike/jekyll-project/_my_collection
An array of the collection's documents.
Input Direct link to this section
{{ site.my_collection.docs.first.url }}
Output Direct link to this section
/my_collection/item.html
An array of static files in the collection.
Input Direct link to this section
{{ site.my_collection.files | size }}
Output Direct link to this section
0
The name of your collection.
Input Direct link to this section
{{ site.my_collection.label }}
Output Direct link to this section
my_collection
Whether the collection's documents will be output as individual files.
Input Direct link to this section
{{ site.my_collection.output }}
Output Direct link to this section
true
The path to the document's source file relative to the site source.
Input Direct link to this section
{{ site.collections.my_collection.relative_path }}
Output Direct link to this section
_my_collection
Document variables Docs
Label of the containing collection.
Input Direct link to this section
{{ site.my_collection.first.collection }}
Output Direct link to this section
my_collection
The content of the collection item, rendered or un-rendered depending upon what Liquid is being processed and the item is.
Input Direct link to this section
{{ site.my_collection.first.content }}
Output Direct link to this section
Hello from my_collection.
The path to the document's source file relative to the site source.
Input Direct link to this section
{{ site.my_collection.first.relative_path }}
Output Direct link to this section
_my_collection/item.md
Global variables Docs
Liquid filters - array Docs
Append characters to a string.
Input Direct link to this section
<!-- page.my_array is ['a', 'b', 'c'] -->
{{ page.my_array | array_to_sentence_string }}
{{ page.my_array | array_to_sentence_string: 'or' }}Output Direct link to this section
a, b, and c
a, b, or cGet the first element of the passed in array.
Input Direct link to this section
<!-- page.my_array is ['a', 'b', 'c'] -->
{{ page.my_array | first }}Output Direct link to this section
a
Group an array's items by a given property.
Input Direct link to this section
<!-- page.people is
- name: "John"
school: "Stanford"
- name: "Jane"
school: "Stanford"
- name: "Joe"
school: "Harvard"
-->
{{ page.people | group_by: "school" }}Output Direct link to this section
{
"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 Direct link to this section
<!-- 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 Direct link to this section
{"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 Direct link to this section
<!-- page.my_array is ['a', 'b', 'c'] -->
{{ page.my_array | join: ', ' }}Output Direct link to this section
a, b, c
Convert Hash or Array to JSON.
Input Direct link to this section
<!-- page.my_array is ['a', 'b', 'c'] -->
{{ page.my_array | jsonify }}Output Direct link to this section
["a","b","c"]
Get the last element of the passed in array.
Input Direct link to this section
<!-- page.my_array is ['a', 'b', 'c'] -->
{{ page.my_array | last }}Output Direct link to this section
c
Accepts an array element's attribute as a parameter and creates a string out of each array element's value.
Input Direct link to this section
<!-- page.people is
- name: "John"
school: "Stanford"
- name: "Jane"
school: "Stanford"
- name: "Joe"
school: "Harvard"
-->
{{ page.people | map: "name" }}Output Direct link to this section
JohnJaneJoe
Adds an object to a array.
Input Direct link to this section
{% assign my_array = "a,b,c" | split:"," %}
{% assign my_array = my_array | push: 'd' %}
{{ my_array | array_to_sentence_string }}Output Direct link to this section
a, b, c, and d
Return the size of an array or string.
Input Direct link to this section
<!-- page.my_array is ['a', 'b', 'c'] -->
{{ page.my_array | size }}Output Direct link to this section
3
Sorts an array.
Input Direct link to this section
<!-- page.my_array is ['c', 'a', 'b'] -->
{{ page.my_array | sort }}Output Direct link to this section
['a','b','c']
You can add a argument to sort on a property name:
Input Direct link to this section
{{ page.posts | sort: 'author' }}
And also add a second argument to say whether the nils should be first or last:
Input Direct link to this section
{{ page.posts | sort: 'author', 'last' }}
Removes duplicate elements from an array.
Input Direct link to this section
<!-- page.my_array is ['cat', 'dog', 'mouse', 'cat'] -->
{{ page.my_array | uniq }}Output Direct link to this section
'cat', 'dog', 'mouse'
Select all the objects in an array where the key has the given value.
Input Direct link to this section
<!-- page.people is
- name: "John"
school: "Stanford"
- name: "Jane"
school: "Stanford"
- name: "Joe"
school: "Harvard"
-->
{{ page.people | where: "school", "Stanford" }}Output Direct link to this section
{"name"=>"John", "school"=>"Stanford"}{"name"=>"Jane", "school"=>"Stanford"}
Select all the objects in an array where the expression is true.
Input Direct link to this section
<!-- 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 Direct link to this section
{"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 Direct link to this section
{{ site.time | date: "%a, %b %d, %y" }}
Output Direct link to this section
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 Direct link to this section
{{ site.time | date_to_long_string }}
Output Direct link to this section
01 January 2016
Convert a Date into RFC-822 format.
Input Direct link to this section
{{ site.time | date_to_rfc822 }}
Output Direct link to this section
Mon, 07 Nov 2008 13:07:54 -0800
Convert a date to short format.
Input Direct link to this section
{{ site.time | date_to_string }}
Output Direct link to this section
01 Jan 2016
Convert a Date into ISO 8601 format.
Input Direct link to this section
{{ site.time | date_to_xmlschema }}
Output Direct link to this section
2008-11-07T13:07:54-08:00
Liquid filters - integer Docs
Liquid filters - string Docs
Prepend the `baseurl` and `url` to the input.
Input Direct link to this section
<!-- baseurl is set to "/mysite" in _config.yml -->
<!-- url is set to "http://example.com" in _config.yml -->
{{ '/images/dog.jpeg' | absolute_url }}Output Direct link to this section
http://example.com/mysite/images/dog.jpeg
Append characters to a string.
Input Direct link to this section
{{ 'jekyll' | append: '.jpg' }}
Output Direct link to this section
jekyll.jpg
Capitalizes the first character.
Input Direct link to this section
{{ "static site generator" | capitalize }}
Output Direct link to this section
Static site generator
Escape a string for use in a URL.
Input Direct link to this section
{{ "foo,bar;baz?" | cgi_escape }}
Output Direct link to this section
foo%2Cbar%3Bbaz%3F
Set a fallback incase a value doesn't exist.
Input Direct link to this section
{{ nil | default: "hello" }}
Output Direct link to this section
hello
Converts a string to lowercase.
Input Direct link to this section
{{ "STATIC Site generator" | downcase }}
Output Direct link to this section
static site generator
Returns an escaped version of html.
Input Direct link to this section
{{ "<p>Jekyll</p>" | escape }}
Output Direct link to this section
&lt;p&gt;Jekyll&lt;/p&gt;
Removes whitespace characters from the beginning of a string.
Input Direct link to this section
{{ ' I love Jekyll! ' | lstrip }}
Output Direct link to this section
I love Jekyll!
Convert a Markdown-formatted string into HTML.
Input Direct link to this section
{{ "Hello **Jekyll**" | markdownify }}
Output Direct link to this section
Hello <strong>Jekyll</strong>
Count the number of words in a string.
Input Direct link to this section
{{ "Hi Jekyll!" | number_of_words }}
Output Direct link to this section
2
Prepend characters to a string.
Input Direct link to this section
{{ 'Jekyll' | prepend: 'I love ' }}
Output Direct link to this section
I love Jekyll
Prepend the `baseurl` value to the input.
Input Direct link to this section
<!-- baseurl is set to "/mysite" in _config.yml -->
{{ '/images/dog.jpeg' | relative_url }}Output Direct link to this section
/mysite/images/dog.jpeg
Removes any occurrence of a substring from a string.
Input Direct link to this section
{{ 'I really really like Jekyll' | remove: 'really' }}
Output Direct link to this section
I like Jekyll
Removes only the first occurrence of a substring from a string.
Input Direct link to this section
{{ 'I really really like Jekyll' | remove_first: 'really' }}
Output Direct link to this section
I really like Jekyll
Replaces any occurrence of a substring from a string.
Input Direct link to this section
{{ 'I really really like Jekyll' | replace: 'really', 'truly' }}
Output Direct link to this section
I truly truly like Jekyll
Replaces only the first occurrence of a substring from a string.
Input Direct link to this section
{{ 'I really really like Jekyll' | replace_first: 'really', 'kinda' }}
Output Direct link to this section
I kinda really like Jekyll
Removes whitespace characters from the end of a string.
Input Direct link to this section
{{ ' I love Jekyll! ' | rstrip }}
Output Direct link to this section
I love Jekyll!
Convert a Sass string into CSS output.
Input Direct link to this section
// assigned to sass_code
body
color: #333
// ignored comment
background-color: yellow
p
/* fixed comment
color: green{{ sass_code | sassify }}
Output Direct link to this section
body {
color: #333;
background-color: yellow;
}
body p {
/* fixed comment */
color: green;
}Convert a SCSS string into CSS output.
Input Direct link to this section
// assigned to scss_code
body {
color: #333;
// ignored comment
background-color: yellow;
p {
/* fixed comment */
color: green;
}
}{{ scss_code | sassify }}
Output Direct link to this section
body {
color: #333;
background-color: yellow;
}
body p {
/* fixed comment */
color: green;
}Return the size of a string.
Input Direct link to this section
<!-- page.my_string is jekyll -->
{{ page.my_string | size }}Output Direct link to this section
6
returns a substring, starting at the specified index.
Input Direct link to this section
{{ "hello" | slice: 0 }}
{{ "hello" | slice: 1 }}
{{ "hello" | slice: 1, 3 }}
{{ "hello" | slice: -2 }}
{{ "hello" | slice: -3, 2 }}Output Direct link to this section
h
e
ell
l
llConvert a string into a lowercase URL slug.
Input Direct link to this section
{{ "The _config.yml file" | slugify }}
Output Direct link to this section
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 Direct link to this section
{{ 'Use "Jekyll" --- the static generator...' | smartify }}
Output Direct link to this section
Use “Jekyll” — the static generator…
Divide a string into an array.
Input Direct link to this section
{{ "a~b" | split:"~" }}
Output Direct link to this section
['a', 'b']
Removes whitespace characters from around a string.
Input Direct link to this section
{{ ' I love Jekyll! ' | strip }}
Output Direct link to this section
I love Jekyll!
Strip all html tags from the input string.
Input Direct link to this section
{{ "<p>Jekyll is cool</p>" | strip_html }}
Output Direct link to this section
Jekyll is cool
Strip all new line characters from the input string.
Input Direct link to this section
{{ "Hello
there" | strip_newlines }}Output Direct link to this section
Hello there
Truncate a string down to x characters.
Input Direct link to this section
{{ "I love Jekyll" | truncate: 12 }}
{{ "I love Jekyll" | truncate: 12, " etc." }}Output Direct link to this section
I love Je...
I love etc.Truncate string down to x words.
Input Direct link to this section
{{ "I love Jekyll" | truncatewords: 2 }}
Output Direct link to this section
I love...
Converts a string to uppercase.
Input Direct link to this section
{{ "static site generator" | upcase }}
Output Direct link to this section
STATIC SITE GENERATOR
URI escape a string.
Input Direct link to this section
{{ "foo, bar \baz?" | uri_escape }}
Output Direct link to this section
foo,%20bar%20%5Cbaz?
Encodes any characters unsafe for a URL.
Input Direct link to this section
{{ "john@example.com" | url_encode }}
Output Direct link to this section
john%40example.com
Select all the objects in an array where the key has the given value.
Input Direct link to this section
{{ "<p>Hi Jekyll</p>"| xml_escape }}
Output Direct link to this section
&lt;p&gt;Hi Jekyll&lt;/p&gt;
Liquid for loops Docs
Condition when there are no items in the array.
Input Direct link to this section
<!-- page.my_array is [] -->
{% for item in page.my_array %}
{{ item }}
{% else %}
There are no items!
{% endfor %}Output Direct link to this section
There are no items!
Returns whether it's the first iteration.
Input Direct link to this section
<!-- page.my_array is [1, 2, 3] -->
{% for item in page.my_array %}
{% if forloop.first %}
First!
{% else %}
Not first
{% endif %}
{% endfor %}Output Direct link to this section
First! Not first Not first
index of the current iteration.
Input Direct link to this section
<!-- page.my_array is ['a', 'b', 'c'] -->
{% for item in page.my_array %}
{{ forloop.index }}
{% endfor %}Output Direct link to this section
1 2 3
index of the current iteration (zero based).
Input Direct link to this section
<!-- page.my_array is ['a', 'b', 'c'] -->
{% for item in page.my_array %}
{{ forloop.index0 }}
{% endfor %}Output Direct link to this section
0 1 2
Returns whether it's the last iteration.
Input Direct link to this section
<!-- page.my_array is [1, 2, 3] -->
{% for item in page.my_array %}
{% if forloop.last %}
Last!
{% else %}
Not last
{% endif %}
{% endfor %}Output Direct link to this section
Not last Not last Last!
Length of the entire loop.
Input Direct link to this section
<!-- page.my_array is ['a', 'b', 'c'] -->
{% for item in page.my_array %}
{{ forloop.length }}
{% endfor %}Output Direct link to this section
3 3 3
Restrict how many items are looped through.
Input Direct link to this section
<!-- page.my_array is [1, 2, 3, 4, 5] -->
{% for item in page.my_array limit: 2 %}
{{ item }}
{% endfor %}Output Direct link to this section
1 2
Start looping from the nth item.
Input Direct link to this section
<!-- page.my_array is [1, 2, 3, 4, 5] -->
{% for item in page.my_array offset: 2 %}
{{ item }}
{% endfor %}Output Direct link to this section
3 4 5
Reverses the order.
Input Direct link to this section
<!-- page.my_array is [1, 2, 3, 4, 5] -->
{% for item in page.my_array reversed %}
{{ item }}
{% endfor %}Output Direct link to this section
5 4 3 2 1
Outputs the number of iterations left.
Input Direct link to this section
<!-- page.my_array is ['a', 'b', 'c'] -->
{% for item in page.my_array %}
{{ forloop.rindex }}
{% endfor %}Output Direct link to this section
3 2 1
Outputs the number of iterations left (zero based).
Input Direct link to this section
<!-- page.my_array is ['a', 'b', 'c'] -->
{% for item in page.my_array %}
{{ forloop.rindex0 }}
{% endfor %}Output Direct link to this section
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 Direct link to this section
<!-- page.name is set to "home" -->
{% case page.name %}
{% when 'home' %}
Home Page
{% when 'about' %}
About Page
{% else %}
Contact Page
{% endcase %}Output Direct link to this section
Home Page
Adds more conditions to an `if` or `unless` block.
Input Direct link to this section
<!-- page.name is set to "contact" -->
{% if page.name == 'about' %}
About Page
{% elsif page.name == 'contact' %}
Contact Page
{% else %}
Other Page
{% endif %}Output Direct link to this section
Contact Page
Executes a block of code only if a certain condition is met.
Input Direct link to this section
<!-- page.name is set to "about" -->
{% if page.name == 'about' %}
About Page
{% endif %}Output Direct link to this section
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 Direct link to this section
<!-- page.name is set to "about" -->
{% unless page.name == "contact" %}
It's not the contact page
{% endunless %}Output Direct link to this section
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 Direct link to this section
{% for i in (1..5) %}
{% if i == 3 %}
{% break %}
{% else %}
{{ i }}
{% endif %}
{% endfor %}Output Direct link to this section
1 2
Causes the loop to skip the current iteration.
Input Direct link to this section
{% for i in (1..5) %}
{% if i == 3 %}
{% continue %}
{% else %}
{{ i }}
{% endif %}
{% endfor %}Output Direct link to this section
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 Direct link to this section
{% for i in (1..5) %}
{% cycle 'red', 'blue', 'yellow' %}
{% endfor %}Output Direct link to this section
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 Direct link to this section
{% decrement my_variable %}
{% decrement my_variable %}
{% decrement my_variable %}Output Direct link to this section
-1
-2
-3Like
increment
, variables declared inside decrement are independent from variables created through assign or capture.Repeatedly executes a block of code.
Input Direct link to this section
{% for page in site.pages %}
{{ page.title }}
{% endfor %}Output Direct link to this section
index
about
contactCreates a new variable and every time it's called the value increases by 1, with the initial value being 0.
Input Direct link to this section
{% increment my_variable %}
{% increment my_variable %}
{% increment my_variable %}Output Direct link to this section
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 Direct link to this section
{% assign my_var = 15 %}
{% increment var %}
{% increment var %}
{% increment var %}
{{ my_var }}Output Direct link to this section
0
1
2
15
Liquid tags - other Docs
Don't output the contained text.
Input Direct link to this section
My name is {% comment %}Mr{% endcomment %} Jekyll
Output Direct link to this section
My name is Jekyll
Code snippet highlighting.
Input Direct link to this section
{% highlight ruby %}
def foo
puts 'foo'
end
{% endhighlight %}Output Direct link to this section
<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 Direct link to this section
<h1>My site</h1>
{% include nav.html %}Output Direct link to this section
<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 Direct link to this section
<h1>My site</h1>
{% include_relative about.html %}Output Direct link to this section
<h1>My Site</h1>
<h1>About</h1>Generate the correct permalink URL for the path you specify.
Input Direct link to this section
{% link _collection/my-document.md %}
{% link _posts/2017-03-15-my-post.md %}
{% link blog/index.html %}
{% link assets/document.pdf %}Output Direct link to this section
/my_collection/custom-permalink/my-document/
/blog/my-post/
/blog/
/assets/document.pdfGenerate the correct permalink URL for a post.
Input Direct link to this section
{% post_url 2010-07-21-name-of-post %}
Output Direct link to this section
/news/2010/07/21/name-of-post/
No liquid will be parsed in within these tags.
Input Direct link to this section
{{ l_bracket}}% raw %{{ r_bracket }}
{% raw %}{{ page.title }}
{% endraw %}Output Direct link to this section
{{ page.title }}
Liquid tags - variable Docs
Create a new variable.
Input Direct link to this section
{% assign my_variable = false %}
{% if my_variable != true %}
Hi there!
{% endif %}Output Direct link to this section
Hi there!
Captures the string inside of the opening and closing tags and assigns it to a variable.
Input Direct link to this section
{% capture my_variable %}
Captured text.
{% endcapture %}
{{ my_variable }}Output Direct link to this section
Captured text.
Markdown Docs
Input Direct link to this section
> Blockquotes are very handy in email to emulate reply text.
> This line is part of the same quote.Output Direct link to this section
<blockquote>
<p>Blockquotes are very handy in email to emulate reply text.
This line is part of the same quote.</p>
</blockquote>Input Direct link to this section
```
def what?
42
end
```
{: .language-ruby}Output Direct link to this section
<pre>
<code class="language-ruby">
def what?
42
end
</code>
</pre>Input Direct link to this section
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 Direct link to this section
<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 Direct link to this section
# H1
## H2
### H3
#### H4
##### H5
###### H6Output Direct link to this section
<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 Direct link to this section
1. First item
2. Second item
3. Third item
* First item
* Second item
* Third itemOutput Direct link to this section
<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 Direct link to this section
A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines
Output Direct link to this section
<p>A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines</p>
Input Direct link to this section
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |Output Direct link to this section
<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 Direct link to this section
**strong** text
_emphasis_ text
`inline` code
[link](http://jekyllrb.com) text
Output Direct link to this section
<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 Direct link to this section
<!-- tags is set to
categories:
- news
-->
{{ page.categories | array_to_sentence_string }}Output Direct link to this section
news
The content of the post, rendered or un-rendered depending upon what Liquid is being processed and what `post` is.
The date assigned to the Post.
Input Direct link to this section
{{ page.date }}
Output Direct link to this section
2016-02-02 00:00:00 -0800
The un-rendered excerpt of the Post.
An identifier unique to the Post.
Input Direct link to this section
{{ page.id }}
Output Direct link to this section
/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 Direct link to this section
{{ page.next.title }}
Output Direct link to this section
/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 Direct link to this section
{{ page.previous.title }}
Output Direct link to this section
/2016/01/02/im-fleeting.html
The list of tags to which this post belongs.
Input Direct link to this section
<!-- tags is set to
tags:
- HTML
- CSS
-->
{{ page.tags | array_to_sentence_string }}Output Direct link to this section
HTML and CSS
The title of the post.
Site variables Docs
The list of all Posts in a category.
Input Direct link to this section
{% for p in site.categories.news %}
{{ p.url }}
{% endfor %}Output Direct link to this section
/2016/01/03/goodbye-world.html
/2016/01/01/hello-world.htmlA list of all the collections.
All the variables set via the command line and your `_config.yml` are available through `site`.
Input Direct link to this section
<!-- url is set to http://mysite.com in the configuration file -->
{{ site.url }}Output Direct link to this section
http://mysite.com
A list containing the data loaded from the YAML, JSON and CSV files located in the _data directory.
Input Direct link to this section
{{ site.data.nba_players.first.name }}
Output Direct link to this section
Michael Jordan
A list of all the documents in every collection.
A subset of `site.pages` listing those which end in `.html`
Input Direct link to this section
{% for p in site.html_pages %}
{{ p.path }}
{% endfor %}Output Direct link to this section
about.html
contact.html
index.htmlA list of all Pages.
Input Direct link to this section
{% for p in site.pages %}
{{ p.path }}
{% endfor %}Output Direct link to this section
about.html
contact.html
index.html
site-map.xmlA reverse chronological list of all Posts.
Input Direct link to this section
{% for p in site.posts %}
{{ p.url }}
{% endfor %}Output Direct link to this section
/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 Direct link to this section
<!-- run on /_posts/2016-01-01-hello-world.md -->
{% for p in site.related_posts %}
{{ p.title }}
{% endfor %}Output Direct link to this section
Goodbye World
Im FleetingA list of all static files (i.e. files not processed by Jekyll's converters or the Liquid renderer).
Input Direct link to this section
{% for file in site.static_files %}
{{ file.path }}
{% endfor %}Output Direct link to this section
/css/style.css
/js/my-script.jsThe list of all Posts with a particular tag.
Input Direct link to this section
{% for p in site.tags.sad %}
{{ p.url }}
{% endfor %}Output Direct link to this section
/2016/01/03/goodbye-world.html
/2016/01/02/im-fleeting.htmlThe current time (when you run the jekyll command).
Input Direct link to this section
{{ site.time }}
Output Direct link to this section
2016-01-28 08:32:19 -0800
Static file variables Docs
The extension name for the file.
Input Direct link to this section
{{ site.static_files.first.extname }}
Output Direct link to this section
.css
The time the file was last modified.
Input Direct link to this section
{{ site.static_files.first.modified_time }}
Output Direct link to this section
1454000258
The relative path to the file.
Input Direct link to this section
{{ site.static_files.first.path }}
Output Direct link to this section
/css/style.css
Yaml Docs
Input Direct link to this section
# Nest hash
my_hash:
subkey:
subsubkey1: 5
subsubkey2: 6
another:
somethingelse: 'Important!'
# Hash of hashes
my_hash: {nr1: 5, nr2: 6}Input Direct link to this section
# sequence
array:
- 132
- 2.434
- 'abc'
# sqeuence of sequences
my_array:
- [1, 2, 3]
- [4, 5, 6]Input Direct link to this section
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