Edit this page on Github

Spress exposes several variables containing site data.

Global

Name Description
site Contains site information and site configuration read from config.yml.
page Page specific data with variables declared at Front matter and metadata files.
spress Contains information about Spress itself.

Site variables

Example of access with Twig: {{ site.categories }}.

Name Type Description
collections array List of all collections. Each element of this list is of type collection. The key of each element is the collection's name.
time string Timestamp when spress command was run.
categories array List of post groups by categories. E.g: site.cagetories.news get all posts with news category. Each element of this list is of type page. Posts are located at src/content/posts.
tags array List of post groups by tags. E.g: site.tags.car get all posts with car tag. Each element of this list is of type page. Posts are located at src/content/posts.
your-variable-name Your custom variables in config.yml are available here. Example: {{ site.your-variable-name }}.

Collection variables

Example of access with Twig: {{ site.collections.collection-name.path }}.

Name Type Description
path string The collection's relative path to src/content folder.
output boolean With a true value the collection's item will be output as individual file.
your-variable-name Your custom variables declared at the collection definition are available here. Example: {{ site.collection-name.your-variable-name }}.

Page variables

Page variables point to the current item in which Spress is working on. Example of access with Twig: {{ page.id }}.

Name Type Description
id string Identifier unique to the item.
collection string The name of the collection assigned to the item.
mtime string The modified time in ISO 8601 format.
filename string The name of the file.
extension string The extension of the file.
path string The relative path to /src/content folder. e.g: about/index.html.
url string The URL of the page without the domain, but with a leading slash. e.g: /about/changelog/.
content string Compiled content.
relationships array Spress >= 2.1 Only available in items belonging to a sorted collection. Contains items related to the current item. Each relationship of this array contains a set of items. Here's an example.

 Additional variables for files with yyyy-mm-dd-title pattern

Name Type Description
title string The title of the page.
title_path string The title obtained from filename. e.g: "hola user" from 2015-12-08-hola-user.md.
date string The date assigned to the post in ISO 8601 format.

 Additional variables for Posts

Name Type Description
categories array List of post categories.
tags array List of post tags.

Spress variables

Example of access with Twig: {{ spress.version }}.

Name Type Description
version string Current version. e.g: 2.0.1-rc
version_id string Version ID. e.g: 20001
major_version string Major version. e.g: 2.
minor_version string Minor version. e.g: 0.
release_version string Release version. e.g: 1.
extra_version string Extra information about the relese. e.g: rc.
external array External variables passed to Spress prior to compiling the site.