Variables

On this page

Rustyll traverses your site looking for files to process. Any files with front matter are subject to processing. For each of these files, Rustyll makes a variety of data available via Liquid. The following is a reference of the available data.

Global Variables

Variable Description
site Site wide information + configuration settings from _config.yml. See below for details.
page Page specific information + the front matter. Custom variables set via the front matter will be available here. See below for details.
layout Layout specific information + the front matter. Custom variables set via front matter in layouts will be available here.
jekyll Jekyll-centric information will be available here. See below for details.
theme Theme-gem specific information as defined in the theme's gemspec. Useful for rendering information in the theme demo's "About" page, for example. See below for details.
content In layout files, the rendered content of the Post or Page being wrapped. Not defined in Post or Page files.
paginator When the paginate configuration option is set, this variable becomes available for use. See Pagination for details.

Site Variables

Variable Description
site.time The current time (when you run the jekyll command).
site.pages A list of all Pages.
site.posts A reverse chronological list of all Posts.
site.related_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 jekyll command with the --lsi (latent semantic indexing) option. Also note GitHub Pages does not support the lsi option when generating sites.
site.static_files A list of all static files (i.e. files not processed by Jekyll's converters or the Liquid renderer). Each file has five properties: path, modified_time, name, basename and extname.
site.html_pages A subset of site.pages listing those which end in .html.
site.html_files A subset of site.static_files listing those which end in .html.
site.collections A list of all the collections (including posts).
site.data A list containing the data loaded from the YAML files located in the _data directory.
site.documents A list of all the documents in every collection.
site.categories.CATEGORY The list of all Posts in category CATEGORY.
site.tags.TAG The list of all Posts with tag TAG.
site.url Contains the url of your site as it is configured in the _config.yml. For example, if you have url: http://mysite.com in your configuration file, then it will be accessible in Liquid as site.url. For the development environment there is an exception, if you are running jekyll serve in a development environment site.url will be set to the value of host, port, and SSL-related options. This defaults to url: http://localhost:4000.
site.[CONFIGURATION_DATA] All the variables set via the command line and your _config.yml are available through the site variable. For example, if you have foo: bar in your configuration file, then it will be accessible in Liquid as site.foo. Jekyll does not parse changes to _config.yml in watch mode, you must restart Jekyll to see changes to variables.

Page Variables

Variable Description
page.content The content of the Page, rendered or un-rendered depending upon what Liquid is being processed and what page is.
page.title The title of the Page or Document resource.
page.excerpt The un-rendered excerpt of a Page or Document. Can be overridden in the front matter. It can either be disabled atomically for certain page or document by setting an empty string to an excerpt_separator key in the front matter of desired resource or disabled site-wide by setting the same as a top-level key in the config file.
page.url The URL of the Post without the domain, but with a leading slash, e.g. /2008/12/14/my-post.html
page.date 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 YYYY-MM-DD HH:MM:SS (assuming UTC), or YYYY-MM-DD HH:MM:SS +/-TTTT (to specify a time zone using an offset from UTC. e.g. 2008-12-14 10:30:00 +0900). Not applicable to Pages.
page.id An identifier unique to a document in a Collection or a Post (useful in RSS feeds). e.g. /2008/12/14/my-post/my-collection/my-document. Not applicable to Pages.
page.categories The list of categories to which this post belongs. Categories are derived from the directory structure above the _posts directory. For example, a post at /work/code/_posts/2008-12-24-closures.md would have this field set to ['work', 'code']. These can also be specified in the front matter. Note: Path-based categories may not work for documents in user-defined collections.
page.collection The label of the collection to which a Document belongs. e.g. posts for a post, or puppies for a document at path _puppies/rover.md. If not part of a collection, an empty string is returned.
page.tags The list of tags to which this post belongs. These can be specified in the front matter.
page.dir The path between the source directory and the file of a page, e.g. /pages/ when the page is at path pages/about.md relative to the source directory. This is derived from the url attribute of the page and can therefore be overridden via the permalink key in the front matter. NOTE: This variable is not applicable to posts and documents in user-defined collections. Use the categories variable to get similar info for posts.
page.name The filename of the post or page, e.g. about.md
page.path The path to the raw post or page, relative to the source directory. Example usage: Using a combination of the repository's blob URL and this page variable to get the full URL to the file in the repository. This can be overridden in the front matter.
page.slug The filename of a Document resource without its extension (or date prefixes for a post). For example, slug for a post at URL /2017/02/22/my-new-post.html, would be my-new-post. Can be overridden in the front matter.
page.ext The file extension of a Document resource. For example, .html. Can be overridden in the front matter.
page.next The next post relative to the position of the current post in site.posts. Returns nil for the last entry.
page.previous The previous post relative to the position of the current post in site.posts. Returns nil for the first entry.
ProTip™: Use Custom Front Matter

Any custom front matter that you specify will be available under page. For example, if you specify custom_css: true in a page's front matter, that value will be available as page.custom_css.

If you specify front matter in a layout, access that via layout. For example, if you specify class: full_page in a layout's front matter, that value will be available as layout.class in the layout and its parents.

Rustyll Variables

Variable Description
jekyll.version Version of Jekyll used to build the site.
jekyll.environment Value assigned to environment variable RUSTYLL_ENV during a build.

Rustyll Performance Variables

Rustyll adds several performance-related variables that can be used in your templates:

Variable Description

site.build_time_ms

The total time taken to build the site in milliseconds

page.build_time_ms

The time taken to build this specific page in milliseconds

site.parallel_pages

The number of pages built in parallel

site.threads

The number of threads used to build the site

Theme Variables

Variable Description
theme.root Absolute path to the theme-gem. Rendered only when environment variable RUSTYLL_ENV is set to development.
theme.authors Comma separated string composed of the authors of the theme-gem.
theme.description Description or summary of the theme-gem as specified in the theme gemspec.
theme.version The version string of current theme.
theme.dependencies List of runtime dependencies of the theme.
theme.metadata A mapping of key-value pairs as defined in the theme gemspec.

Paginator

Variable Description
paginator.page The number of the current page
paginator.per_page Number of posts per page
paginator.posts Posts available for the current page
paginator.total_posts Total number of posts
paginator.total_pages Total number of pages
paginator.previous_page The number of the previous page, or nil if no previous page exists
paginator.previous_page_path The path to the previous page, or nil if no previous page exists
paginator.next_page The number of the next page, or nil if no subsequent page exists
paginator.next_page_path The path to the next page, or nil if no subsequent page exists
Paginator variable availability

These are only available in index files, however they can be located in a subdirectory, such as /blog/index.html.

Caching Variables

Rustyll offers caching variables that can help optimize your templates:

Variable Description

site.cached

Boolean indicating if the current build is using cached data

page.cached

Boolean indicating if the current page was loaded from cache

site.cache_strategy

The current cache strategy being used (normal, aggressive, conservative)

Search Rustyll

Type to find a page.