collection
Label of the containing collection.
Input
{{ site.my_collection.first.collection }}Output
my_collectioncontent
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.relative_path
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
Document Variables
directory
The full path to the collections’s source directory.
Input
{{ site.my_collection.directory }}Output
/Users/mike/jekyll-project/_my_collectiondocs
An array of the collection’s documents.
Input
{{ site.my_collection.docs.first.url }}Output
/my_collection/item.htmlfiles
An array of static files in the collection.
Input
{{ site.my_collection.files | size }}Output
0label
The name of your collection.
Input
{{ site.my_collection.label }}Output
my_collectionoutput
Whether the collection’s documents will be output as individual files.
Input
{{ site.my_collection.output }}Output
truerelative_path
The path to the document’s source file relative to the site source.
Input
{{ site.collections.my_collection.relative_path }}Output
_my_collection
Collection Variables
content
In layout files, the rendered content of the Post or Page being wrapped. Not defined in Post or Page files.
page
Page specific information + the YAML front matter. Custom variables set via the YAML Front Matter will be available here.
paginator
When the paginate configuration option is set, this variable becomes available for use.
site
Sitewide information + configuration settings from
_config.yml.
Global Variables
append
Append characters to a string.
Input
{{ 'jekyll' | append: '.jpg' }}Output
jekyll.jpgcapitalize
Capitalizes the first character.
Input
{{ "static site generator" | capitalize }}Output
Static site generatorcgi_escape
Escape a string for use in a URL.
Input
{{ "foo,bar;baz?" | cgi_escape }}Output
foo%2Cbar%3Bbaz%3Fdefault
Set a fallback incase a value doesn’t exist.
Input
{{ nil | default: "hello" }}Output
hellodowncase
Converts a string to lowercase.
Input
{{ "STATIC Site generator" | downcase }}Output
static site generatorescape
Returns an escaped version of html.
Input
{{ "<p>Jekyll</p>" | escape }}Output
&lt;p&gt;Jekyll&lt;/p&gt;lstrip
Removes whitespace characters from the beginning of a string.
Input
{{ ' I love Jekyll! ' | lstrip }}Output
I love Jekyll!markdownify
Convert a Markdown-formatted string into HTML.
Input
{{ "Hello **Jekyll**" | markdownify }}Output
Hello <strong>Jekyll</strong>number_of_words
Count the number of words in a string.
Input
{{ "Hi Jekyll!" | number_of_words }}Output
2prepend
Prepend characters to a string.
Input
{{ 'Jekyll' | prepend: 'I love ' }}Output
I love Jekyllremove_first
Removes only the first occurrence of a substring from a string.
Input
{{ 'I really really like Jekyll' | remove_first: 'really' }}Output
I really like Jekyllremove
Removes any occurrence of a substring from a string.
Input
{{ 'I really really like Jekyll' | remove: 'really' }}Output
I like Jekyllreplace_first
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 Jekyllreplace
Replaces any occurrence of a substring from a string.
Input
{{ 'I really really like Jekyll' | replace: 'really', 'truly' }}Output
I truly truly like Jekyllrstrip
Removes whitespace characters from the end of a string.
Input
{{ ' I love Jekyll! ' | rstrip }}Output
I love Jekyll!sassify
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; }scssify
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; }size
Return the size of a string.
Input
<!-- page.my_string is jekyll --> {{ page.my_string | size }}Output
6slice
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 llslugify
Convert a string into a lowercase URL slug.
Input
{{ "The _config.yml file" | slugify }}Output
the-config-yml-fileThe 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._~!$&'()+,;=@
smartify
Convert quotes into smart quotes with SmartyPants
Input
{{ 'Use "Jekyll" --- the static generator...' | smartify }}Output
Use “Jekyll” — the static generator…split
Divide a string into an array.
Input
{{ "a~b" | split:"~" }}Output
['a', 'b']strip_html
Strip all html tags from the input string.
Input
{{ "<p>Jekyll is cool</p>" | strip_html }}Output
Jekyll is coolstrip_new_lines
Strip all new line characters from the input string.
Input
{{ "Hello there" | strip_new_lines }}Output
Hello theretextilize
Convert a Textile-formatted string into HTML.
Input
{{ "h1. Hello Jekyll" | textilize }}Output
<h1>Hello Jekyll</h1>truncate
Truncate a string down to x characters.
Input
{{ "I love Jekyll" | truncate: 12 }}Output
I love Je...truncatewords
Truncate string down to x words.
Input
{{ "I love Jekyll" | truncatewords: 2 }}Output
I love...upcase
Converts a string to uppercase.
Input
{{ "static site generator" | upcase }}Output
STATIC SITE GENERATORuri_escape
URI escape a string.
Input
{{ "foo, bar \baz?" | uri_escape }}Output
foo,%20bar%20%5Cbaz?url_encode
Encodes any characters unsafe for a URL.
Input
{{ "[email protected]" | url_encode }}Output
john%40example.comxml_escape
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;array_to_sentence_string
Append characters to a string.
Input
<!-- page.my_array is ['a', 'b', 'c'] --> {{ page.my_array | array_to_sentence_string }}Output
a, b, and cfirst
Get the first element of the passed in array.
Input
<!-- page.my_array is ['a', 'b', 'c'] --> {{ page.my_array | first }}Output
agroup_by
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" }] }join
Joins an array with the specified character.
Input
<!-- page.my_array is ['a', 'b', 'c'] --> {{ page.my_array | join: ', ' }}Output
a, b, cjsonify
Convert Hash or Array to JSON.
Input
<!-- page.my_array is ['a', 'b', 'c'] --> {{ page.my_array | jsonify }}Output
["a","b","c"]last
Get the last element of the passed in array.
Input
<!-- page.my_array is ['a', 'b', 'c'] --> {{ page.my_array | last }}Output
cmap
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
JohnJaneJoepush
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 dsize
Return the size of an array or string.
Input
<!-- page.my_array is ['a', 'b', 'c'] --> {{ page.my_array | size }}Output
3sort
Sorts an array.
Input
<!-- page.my_array is ['c', 'a', 'b'] --> {{ page.my_array | sort }}Output
['a','b','c']uniq
Removes duplicate elements from an array.
Input
<!-- page.my_array is ['cat', 'dog', 'mouse', 'cat'] --> {{ page.my_array | uniq }}Output
'cat', 'dog', 'mouse'where
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"}ceil
Rounds a number up to the nearest whole number.
Input
{{ 1.2 | ceil }}Output
2divided_by
Integer division.
Input
{{ 10 | divided_by:3 }}Output
3floor
Rounds a number down to the nearest whole number.
Input
{{ 1.2 | floor }}Output
1minus
Subtraction.
Input
{{ 4 | minus:1 }}Output
3modulo
Remainder.
Input
{{ 3 | modulo:2 }}Output
1plus
Addition.
Input
{{ 4 | plus:1 }}Output
5round
Rounds a number to the nearest whole number.
Input
{{ 1.8 | round }}Output
2times
Integer multiplication.
Input
{{ 10 | times:3 }}Output
30date_to_long_string
Convert a date to long format.
Input
{{ site.time | date_to_long_string }}Output
01 January 2016date_to_long_rfc822
Convert a Date into RFC-822 format.
Input
{{ site.time | date_to_rfc822 }}Output
Mon, 07 Nov 2008 13:07:54 -0800date_to_string
Convert a date to short format.
Input
{{ site.time | date_to_string }}Output
01 Jan 2016date_to_xmlschema
Convert a Date into ISO 8601 format.
Input
{{ site.time | date_to_xmlschema }}Output
2008-11-07T13:07:54-08:00date
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
Liquid Filters
String
Array
Integer
Date
else
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!first
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 firstindex
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 3index0
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 2last
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
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 3limit
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 2offset
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 5reversed
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 1rindex
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 1rindex0
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 For Loops
assign
Create a new variable.
Input
{% assign my_variable = false %} {% if my_variable != true %} Hi there! {% endif %}Output
Hi there!capture
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.break
Causes the loop to stop iterating.
Input
{% for i in (1..5) %} {% if i == 3 %} {% break %} {% else %} {{ i }} {% endif %} {% endfor %}Output
1 2continue
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 5cycle
Loops through a group of strings and outputs them in the order that they were passed as parameters.
cyclemust be used within a for loop block.Input
{% for i in (1..5) %} {% cycle 'red', 'blue', 'yellow' %} {% endfor %}Output
red blue yellow red bluedecrement
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.for
Repeatedly executes a block of code.
Input
{% for page in site.pages %} {{ page.title }} {% endfor %}Output
index about contactincrement
Creates 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
incrementtag are independent from variables created throughassignorcapture.In the example below,
my_varis created throughassign. Theincrementtag is then used several times on a variable with the same name. However, note that theincrementtag does not affect the value ofmy_varthat was created throughassign.Input
{% assign my_var = 15 %} {% increment var %} {% increment var %} {% increment var %} {{ my_var }}Output
0 1 2 15case
Creates a switch statement to compare a variable with different values.
caseinitializes the switch statement, andwhencompares 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 Pageelsif
Adds more conditions to an
iforunlessblock.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 Pageif
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 Pageoperations
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
unless
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 pageWhich is the same as doing:
{% if page.name != "contact" %} It's not the contact page {% endif %}comment
Don’t output the contained text.
Input
My name is {% comment %}Mr{% endcomment %} JekyllOutput
My name is Jekyllgist
Embed a GitHub Gist.
Input
{% gist parkr/931c1c8d465a04042403 %}Output
<noscript><pre> <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>503 backend read error</title> </head> <body> <h1>Error 503 backend read error</h1> <p>backend read error</p> <h3>Guru Mediation:</h3> <p>Details: cache-lax1435-LAX 1453942175 1299394840</p> <hr> <p>Varnish cache server</p> </body> </html> </pre></noscript><script src="https://gist.github.com/parkr/931c1c8d465a04042403.js"> </script>highlight
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>include
Inserts a file from the
_includesdirectory.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>include_relative
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>post_url
Generate the correct permalink URL.
Input
{% post_url 2010-07-21-name-of-post %}Output
/news/2010/07/21/name-of-post/raw
No liquid will be parsed in within these tags.
Input
~~~liquid{% raw %} {{ page.title }} {% endraw %} ~~~
Output
{{ page.title }}
Liquid Tags
Variable
Iteration
Control Flow
Other
blockquotes
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>code blocks
Input
``` def what? 42 end ``` {: .language-ruby}Output
<pre> <code class="language-ruby"> def what? 42 end </code> </pre>definition list
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>headings
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>horizontal rules
Input
---Output
<hr />lists
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>paragraphs
Input
A paragraph is simply one or more consecutive lines of text, separated by one or more blank linesOutput
<p>A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines</p>tables
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>text markup
Input
**strong** text _emphasis_ text `inline` code [link](http://jekyllrb.com) text 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>
Markdown
path
The path to the raw post or page.
Input
{{ page.path }}Output
index.htmlurl
The URL of the Post without the domain, but with a leading slash.
Input
{{ page.url }}Output
/index.html
Page Variables
next_page_path
path of next pagination page, or nil if no subsequent page exists.
Input
{{ paginator.next_page_path }}Output
/blog/4next_page
page number of the next pagination page, or
nilif no next page exists.Input
{{ paginator.next_page }}Output
4page
Current page number.
Input
{{ paginator.page }}Output
1per_page
Number of posts per page.
Input
{{ paginator.per_page }}Output
5posts
A list of posts for the current page.
Input
{% for post in paginator.posts %} {{ post.id }} {% endfor %}Output
/2016/01/03/no-im-not /2016/01/04/im-back /2016/01/03/goodbye-world /2016/01/02/im-fleetingprevious_page_path
path of previous pagination page, or nil if no previous page exists.
Input
{{ paginator.previous_page_path }}Output
/blog/2previous_page
page number of the previous pagination page, or
nilif no previous page exists.Input
{{ paginator.previous_page }}Output
2total_pages
Number of pagination pages.
Input
{{ paginator.total_pages }}Output
6total_posts
Total number of posts in the site.
Input
{{ paginator.total_posts }}Output
37
Paginator Variables
categories
The list of categories to which this post belongs.
Input
<!-- tags is set to categories: - news --> {{ page.categories | array_to_sentence_string }}Output
newscontent
The content of the post, rendered or un-rendered depending upon what Liquid is being processed and what
postis.Input
{{ page.content }}Output
Hello World!date
The date assigned to the Post.
Input
{{ page.date }}Output
2016-02-02 00:00:00 -0800excerpt
The un-rendered excerpt of the Post.
Input
{{ page.excerpt }}Output
Hello World!id
An identifier unique to the Post.
Input
{{ page.id }}Output
/2015/10/11/hello-worldnext
The next post relative to the position of the current post in
site.posts. Returnsnilfor the last entry.Input
{{ page.next.title }}Output
/2016/01/02/hello-world.htmlprevious
The previous post relative to the position of the current post in
site.posts. Returnsnilfor the first entry.Input
{{ page.previous.title }}Output
/2016/01/02/im-fleeting.htmltags
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 CSStitle
The title of the post.
Input
{{ page.title }}Output
Hello World
Post Variables
categories.category
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.htmlcollections
A list of all the collections.
Input
{{ site.collections | size }}Output
1configuration data
All the variables set via the command line and your
_config.ymlare available throughsite.Input
<!-- url is set to http://mysite.com in the configuration file --> {{ site.url }}Output
http://mysite.comdata
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 Jordandocuments
A list of all the documents in every collection.
Input
{{ site.documents | size }}Output
19html_pages
A subset of
site.pageslisting those which end in.htmlInput
{% for p in site.html_pages %} {{ p.path }} {% endfor %}Output
about.html contact.html index.htmlpages
A list of all Pages.
Input
{% for p in site.pages %} {{ p.path }} {% endfor %}Output
about.html contact.html index.html site-map.xmlposts
A 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.htmlrelated_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.
Input
<!-- run on /_posts/2016-01-01-hello-world.md --> {% for p in site.related_posts %} {{ p.title }} {% endfor %}Output
Goodbye World Im Fleetingstatic_files
A 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.jstags.tag
The 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.htmltime
The current time (when you run the jekyll command).
Input
{{ site.time }}Output
2016-01-28 08:32:19 -0800
Site Variables
extname
The extension name for the file.
Input
{{ site.static_files.first.extname }}Output
.cssmodified_time
The time the file was last modified.
Input
{{ site.static_files.first.modified_time }}Output
1454000258path
The relative path to the file.
Input
{{ site.static_files.first.path }}Output
/css/style.css
Static File Variables
hashes
Input
# Nest hash my_hash: subkey: subsubkey1: 5 subsubkey2: 6 another: somethingelse: 'Important!' # Hash of hashes my_hash: {nr1: 5, nr2: 6}sequences
Input
# sequence array: - 132 - 2.434 - 'abc' # sqeuence of sequences my_array: - [1, 2, 3] - [4, 5, 6]variables
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