Variables

Cobalt makes a variety of data availale as Liquid variables.

This is can be helpful for:

  • Theming
  • Easier maintenance for only having one place to update things

Example:

<html>
  <head>
    <title>{{ page.title }}</title>
  </head>
  <body>
  {{ page.content }}
  </body>
</html>

Global variables

Variable Format Description
site Object Site-wide information
page Object Current-page information
collection Object Built-in posts.

Site Variables

Variable Format Description
site.title String The title of the entire site, see _cobalt.yml.
site.description String The description of the entire site, see _cobalt.yml.
site.base_url String The URL of your site, see _cobalt.yml. This is helpful for making absolute URLs, particularly when run within cobalt serve.
site.data Object The merged result of _data and site: data.

Page Variables

In the context of your page content:

Variable Format Description
page.permalink String Relative path to the page, see frontmatter.
page.title String The title of the page, see frontmatter.
page.slug String The identifier of the page, see frontmatter.
page.description String The description of the page, see frontmatter.
page.categories List of Strings Hierarchical categories this page lives under, see frontmatter.
page.published_date YYYY-MM-DD HH:MM:SS TZ The date the page was initially published, see frontmatter.
page.is_draft Boolean See frontmatter.
page.file.permalink String Relative path to the source file.
page.collection String The slug of the page's collection. "posts" for posts.
page.data Object User-defined data, see frontmatter.

Additionally, in the context of your page layout:

Variable Format Description
page.content String The rendered page content (i.e. excludes the layout).
page.excerpt String The rendered excerpt of a page, see excerpt / excerpt_separator.

Collection Variables

Below, the built-in posts collection is demonstrated.

Variable Format Description
collections.posts.title String The title of the posts collection, see _cobalt.yml.
collections.posts.description String The description of the posts collection, see _cobalt.yml.
collections.posts.slug String The identifier of the posts collection, see _cobalt.yml.
collections.posts.rss String The permalink for the posts' RSS feed, see _cobalt.yml and RSS.
collections.posts.jsonfeed String The permalink for the posts' RSS feed, see _cobalt.yml.