Public API
In templates the following 3 variables are available:
site
: The global site objectpage
: The current page objectlayout
: The current layout
The site
object has the following public properties:
url
: URL from configuration file unless running inserve
mode, in which case it will point tolocalhost
. In general it should not be necessary to accesssite.url
, instead usepath_to_url
filter or theurl
property of the resource you need.time
: The timeglim
was started.data
: JSON, YAML, and CSV files read from_data
indexed by file basename.collections
: Collection objects indexed by name of the collection.pages
: Files outside collections that have front matter.html_pages
: Files outside collections that have front matter and an.html
extension.static_files
: Files outside collections that do not have front matter.html_files
: Files outside collections that do not have front matter but do have an.html
extension.documents
: Files from collections (including posts) regardless of front matter.posts
: Files from theposts
collection that have front matter.related_posts
: Empty array.categories
: Categories from files in theposts
collection. Indexed by category name with value being array of posts.tags
: Tags from files in theposts
collection (array of strings). Indexed by tag name with value being array of posts.
The collection
object (available as site.collections.«collection»
) has the following public properties:
label
: The name of the collection.docs
: Files in the collection that have front matter.files
: Files in the collection that do not have front matter.categories
: Objects indexed by category name, the objects are page objects if category page generation is enabled, otherwise the objects only exposetitle
andposts
as public properties.tags
: Same as with categories but indexed by tag.relative_directory
: The directory containing the files relative to source directory.directory
: The absolute path for the collection’s directory.
The page
object has the following public properties:
url
: The URL for the page. Unlike Jekyll, this will be an absolute URL.date
: The date of the page, either from the front matter, file name prefix (yyyy-mm-dd
), or file’s last modified date.path
: The local path of the page.relative_path
: Path relative to the source directory.name
: The file name without directory.basename
: The file name without directory and extension.extname
: The file extension including period, e.g..html
.collection
: The collection label when the page is part of a collection.next
: If the page is part of a collection, this is the next page in that collection.previous
: If the page is part of a collection, this is the previous page in that collection.content
: This is the content after running converters but before rendering the page’s potential layout.output
: This is the finished page as it will be written to disk.excerpt
: For pages with an excerpt separator, this is the excerpt. If there is no excerpt separator then it defaults to the content.
When pagination is enabled, the page has a paginator
object with the API explained previously.
Additionally all values set in the configuration file are available through the site
object, and all values set in a page’s front matter (or via the defaults
system) are available through the page
object.
The layout
object only serves to expose potential front matter set for the current or any parent layout.