Within the templates files, apart from our standard html, we also have access to any variables defined within the .yml file that corresponds to the current page. These can be accessed by using page. followed by the key.
ie. page.title
In addition, any variables defined in /content/_shared.yml are available within all template files.
Stacey-created variables
These are created for each page within the site.
- page.root_path
- Will output a relative path from the current page to the root of the site.
ie. in /projects/project-name/_page.root_path will contain _../../. - page.thumb
- Outputs the relative url to the thumbnail for this page (if one exists).
- page.url
- Outputs the relative path to this page from the page currently being viewed (ie. ../../projects/project-1).
- page.permalink
- Outputs the absolute url path of the current page (ie. projects/project-1).
- page.slug
- Outputs the slug of the current page (ie. project-1).
- page.is_current
- Returns true if page.permalink matches the server’s request uri.
- page.is_first
- Returns true if current page is the first in its collection.
- page.is_last
- Returns true if current page is the last in its collection.
- page.page_name
- Outputs the name of the current page.
This is constructed by converting the page’s slug into title-case text
(ie. test-project-1 becomes Test Project 1). - page.siblings_count
- The number of pages sitting at the same level as this page (ie. 12).
- page.children_count
- The number of children below this page (ie. 12).
- page.index
- The number of the current page, relative to the other pages sitting at the same level (ie. 5).
- page.current_year
- Will output the current year.
- page.domain_name
- Will output the domain name of the current site (ie. staceyapp.com).
- page.base_url
- Will output the domain name and folder path Stacey is running from
(ie. staceyapp.com/stacey). - page.site_updated
- Will output the date the site was last edited in the RFC 3339 format
(ie. 2009-12-12T17:34:23+11:00). - page.updated
- Will output the date the current page was last edited in the RFC 3339 format (ie. 2009-12-12T17:34:23+11:00).
- page.stacey_version
- Will output the version of Stacey you are running (ie. 3.0.0).
- page.file_path
- Will output the full file system path to the current page. (ie. /content/3.about)
YAML-file variables
This variable can be used from within your YAML files.
- bypass_cache
- If set to true, will bypass Stacey's caching mechanisms for this page.