Variables
Bridgetown traverses your site looking for files to process. Any files with front matter are subject to processing. For each of these files, Bridgetown makes a variety of data available via the Liquid template language. The following is a reference of the available data.
Global Variables #
Variable | Description |
---|---|
|
Site wide information + configuration settings from |
|
Resource front matter and other content. Custom variables set via the front matter will be available here. See below for details. |
|
Layout specific information + the front matter. Custom variables set via front matter in layouts will be available here. |
|
In layout files, the rendered content of the resource being wrapped. Not defined in resource files themselves. |
Site Variables #
Variable | Description |
---|---|
|
The current time (when you run the |
|
A list of all resources (from pages, posts and other collections). |
|
A list of all static files (i.e. files not processed by Bridgetown's converters or the Liquid renderer). Each file has five properties: |
|
A list of all the collections (including posts). |
|
A list containing the data loaded from the YAML files located in the |
|
The list of all resources in category |
|
The list of all resources with tag |
|
Contains the url of your site as it is configured in the |
|
You can put metadata variables in |
|
All the variables set via the command line and your |
Resource Variables #
Variable | Description |
---|---|
|
The content of the resource. |
|
An excerpt of the resource from the configured summary service. |
|
The URL of the resource without the domain, but with a leading slash, e.g. |
|
The Date assigned to the resource. This can be overridden in front matter by specifying a new date/time in the format |
|
An identifier unique to the resource and its collection (useful in RSS feeds). e.g. |
|
The list of categories to which this post belongs, which can be specified in the front matter. |
|
The collection to which this resource belongs. Information on collection variables here. If not part of a collection, nothing is returned. |
|
The list of tags to which this post belongs. These can be specified in the front matter. |
|
The path of the resource relative to the source folder. |
|
The next resource relative to the position of the current resource in its collection. Returns |
|
The previous resource relative to the position of the current resource in its collection. Returns |
Top Tip: Use Custom Front Matter
Any custom front matter that you specify will be available under
resource
. For example, if you specify custom_css: true
in a resource’s front matter, that value will be available as resource.data.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.data.class
in the layout.