📘

Quick links

Global variables

Example

Display the current date

{{ today }}

List of all the global variables

NameTypeDescription
siteSitecurrent site. Can not be used by itself. Please refer to the properties of the site
pagePagecurrent page. Can not be used by itself. Please refer to the properties of the page
wagonBooleanTrue if the page is rendered by Wagon or not (i.e. Engine).
sessionHashall the variables stored in the current session
paramsHashall the GET params of the current request
hostStringhost of the server (+ port if different from 80)
base_urlStringscheme (http or https) + host of the server (+ port if different from 80 or 443).
ip_addressStringIP Address of the computer doing the request
pathStringHTTP request path
fullpathStringHTTP request full path (includes query string if present)
urlStringHTTP request url
http_methodStringHTTP request method
refererStringFull path of referring page (includes query string if present)
headBooleanTrue if the request is a HTTP head
getBooleanTrue if the request is a HTTP get
postBooleanTrue if the request is a HTTP post
putBooleanTrue if the request is a HTTP put
deleteBooleanTrue if the request is a HTTP delete
nowTimecurrent time (UTC)
todayDatecurrent date
localeStringcurrent locale
default_localeStringdefault locale of the current site
localesArrayall the locales handled by the current site

Site

Example

Display the name of the current site

{{ site.name }}

Attributes

NameTypeDescription
nameStringname of the site
indexPageroot page of the site
pagesArrayall the pages including even sub pages
domainsArraylist of all the domains the site answers for
seo_titleStringalternative title for the site used for SEO purpose
meta_keywordsStringkeywords used for SEO purpose
meta_descriptionStringdescription used for SEO purpose
metafieldsCollectioncustom fields stored under custom namespaces (Syntax: {{ site.metafields.<namespace>.<field> }}); see Site metafields

Page

Example

Display the title of the current page

{{ page.title }}

Attributes

NameTypeDescription
titleStringtitle of the page
fullpathStringthe complete full path
slugStringunique identifier for urls, the same as a permalink
handleStringunique identifier for the page (useful for link_to for example)
parentPagethe parent page. Nil if the page is the root
childrenArraythe direct children
breadcrumbsArraythe parent pages and the page itself
depthIntegerthe depth in the tree of pages
redirectBooleantrue if the page is a redirection.
redirect_urlStringURL to a remote or a local page.
listedBooleantrue if the page is included in the menu
publishedBooleantrue if the page is published
seo_titleStringalternative title for the page used for SEO purpose
meta_keywordsStringkeywords used for SEO purpose
meta_descriptionStringdescription used for SEO purpose
templatizedBooleantrue if this page is a template
content_typeContent typeexample: {{page.content_type.count }}
editable_elementsStringvalue of an editable element.
syntax: page.editable_elements.<block names separated by a .>..
example:
{{ page.editable_elements.content.main.title }}

Content types

Example

Display the number of elements of the entries stored in the Projects model.

{{ contents.projects.size }}

Syntax

{{ contents.<name> }}

name is the slug attribute of your content type.

Attributes

NameTypeDescription
firstContentEntryFirst entry of the collection
lastContentEntryLast entry of the collection
emptyBooleanTrue if the collection of entries is empty
anyBooleanTrue if the collection of entries is NOT empty
sizeIntegerThe total number of entries
countIntegerAlias for size
lengthIntegerAlias for size
group_by_ArrayThe field name is the name of a "Select" type field of the content type. The method returns an ordered Array of Hash. Each Hash stores 2 keys, name which is the name of the option and entries which is the list of the ordered entries for the option. The Array is ordered based on the order of the options set in the back-office.
_optionsArrayThe field name is the name of a "Select" type field of the content type. The method returns an ordered Array of available options.

Content entry

Example

Display the name of the first projects. "name" being one of the custom fields described in the content type "Projects".

{{ contents.projects.first.name }}

Attributes

NameTypeDescription
_labelStringthe label as displayed in the back-office to identify the entry
_permalinkStringunique identifier for urls
_slugStringalias for _permalink
nextContentEntrythe next entry for the parent content type based on the order defined in the back-office. Nil if no entry found
previousContentEntrythe next entry for the parent content type based on the order defined in the back-office. Nil if no entry found
seo_titleStringalternative title for the entry used for SEO purpose
meta_keywordsStringkeywords used for SEO purpose
meta_descriptionStringdescription used for SEO purpose
created_atDateEntry creation date time (automatically set)