Exploring the Variables Created by Jekyll for Liquid
13 Aug 2015 | GitHub Pages, Jekyll, LiquidJekyll creates variables for Liquid from three locations:
- Your site’s
_config.yml
file (read more) - Other
yml
files in the_data
folder (read more) - YAML Front Matter in any other file (read more)
Which means in addition to the standard variables, you can specify your own.
Site Variables
The site
variable is the root object for the site, represented as a Ruby hash. This is a very large object since it contains the entire site, its meta data, and other build-time artifacts, but here are some interesting variables from this site:
Variable | Contents | Origin |
---|---|---|
site.url | http://downtothewire.io | User |
site.baseurl | User | |
site.title | Down to the Wire | User |
site.permalink | pretty | User |
site.time | 2018-11-22 23:52:14 +0000 | Jekyll |
Data Variables
The data
variable is the union of all of the yml
files in the _data
folder and is accessible from the site
variable. Each yml
file adds another object with the same name as its source file. If there are no data files, then this object is empty.
On this site, I use ghpaghes-ghcomments and tags, and each has its own file: gpgc.yml
and tags.yml
. Here are some interesting variables from them:
Variable | Contents | Origin |
---|---|---|
site.data.gpgc.repo_owner | wireddown | User |
site.data.gpgc.repo_name | wireddown.github.io | User |
site.data.tags[0] | {"slug"=>"vikit", "name"=>"VIKit"} | User |
Page Variables
The page
variable is the object for a page. Often, the variable is renamed to post
by layout or include files. Here are interesting variables from this page:
Variable | Contents | Origin |
---|---|---|
page.layout | post | User |
page.title | Exploring the Variables Created by Jekyll for Liquid | User |
page.date | 2015-08-13 00:00:00 +0000 | Jekyll |
page.path | _posts/2015-08-13-exploring-the-variables-created-by-jekyll-for-liquid.md | Jekyll |
page.id | /2015/08/13/exploring-the-variables-created-by-jekyll-for-liquid | Jekyll |
page.url | /2015/08/13/exploring-the-variables-created-by-jekyll-for-liquid/ | Jekyll |
page.tags | github-pages jekyll liquid | User |