Variables

Herbie crawls certain directories of the website and processes text files that contain a page properties block. For each of these files, different data is generated and made available in the templating system.

To avoid polluting the global namespace, this data is wrapped in three objects. These objects can be accessed in the layout and content files using normal Twig variables.

Here are some examples:

{{ content.default|raw }}
{{ page.title }}
{{ page.layout }}
{{ site.language }}
{{ site.route }}

More details on these variables are provided below.

Global variables

Variable Description Type
content

The rendered content with one or more content segments. Available only in layout files.

array
page

The page object with its properties and methods.

herbie\Page
site

The site object with its properties and methods.

herbie\Site

Content variables

Variable Description Type
content.default

The default content segment to be displayed. This is always available.

string
content.<name>

Other named content segments depending on the segments used in your layout files.

string

Page variables

Page variables are defined in the page properties block.

Variable Description Type
page.authors

One or more authors of the page.

string[]
page.cached

If set, the rendered page may be cached (only effective when caching is enabled).

bool
page.cache_id

Computed read-only cache identifier for the page (page-<id>). Not a stored field and not included in toArray().

string
page.categories

One or more categories that belong to the page.

string[]
page.content_type

Content-Type of the HTTP response. Defaults to text/html and can be overridden in front matter; it is not derived automatically from file extension or format.

string
page.created

Creation time of the page. Not set automatically; valid values are formatted as ISO 8601 (c).

string
page.date

Date of the page. Set explicitly, taken from a date prefix in the file name (YYYY-MM-DD...) when loading from file, or derived from the file modification time.

string
page.excerpt

Optional excerpt text. This is a manual field in core and is not automatically extracted from the page body.

string
page.format

Page content format/formatter. When loading from file, it is taken from the file extension if not set. Values are normalized to markdown (md/markdown), textile, rst, or raw.

string
page.hidden

If true, the page is not visible in navigation elements like menu, sitemap, or breadcrumb. For file-based pages, it defaults to true when the file name has no numeric prefix (unless explicitly set).

bool
page.id

Aliased page ID, for example @page/2-company/3-about-us.md. Set automatically when loading from file if not provided.

string
page.keep_extension

If true, the file extension is kept in the URL/route. Useful for pages like XML sitemaps or robots.txt.

bool
page.layout

Layout basename without file extension. Layout files are located in site/themes/<theme>/ and use the extension configured by fileExtensions.layouts (default twig). An empty value renders without a layout wrapper.

string
page.menu_title

Title used in navigation elements like menu, sitemap, or breadcrumb. When read and empty, it falls back to page.title.

string
page.modified

Modification time of the page as an ISO 8601 (c) formatted string. Set automatically from the file modification time when loading from file if not provided.

string
page.parent_id

Aliased parent page ID, for example @page/2-company/1-index.md. Determined automatically when loading from file if not provided.

string
page.parent_route

Parent route of the page, for example company. Derived automatically when loading from file if not provided.

string
page.path

Path to the page file. Set automatically when loading from file if not provided.

string
page.redirect

Redirect target. Can be set as a route string or as [url, status]; strings are normalized to [url, 302]. Stored/read value is an array ([] or [url, status]) with status code 300-308.

string|array
page.route

Route of the page, for example company/about-us. Derived automatically from the alias/file name when loading from file if not provided.

string
page.segments

Page content as an associative array of segments (including default). Lazy-loaded from the page file on first access if not already provided.

array
page.tags

One or more tags that belong to the page.

string[]
page.title

Title of the page.

string
page.twig

If true, the page is processed by the Twig renderer before rendering.

bool
page.type

Page type.

string
page.<name>

Any number of custom variables defined in front matter or set programmatically.

mixed

Site variables

Variable Description Type
site.base_url

The base url.

string
site.charset

The charset (default: UTF-8)

string
site.config

The config object with its methods.

Config
site.created

The time of the last recent created page in ISO-8601 format (2004-02-12T15:19:21+00:00).

string
site.data.<name>

Project wide data structures, which are located in site/data.

mixed
site.language

The language as 2-digit ISO-code (default: de)

string
site.locale

The locale settings (default: de_DE.UTF-8)

string
site.modified

The time of the last modified page in ISO-8601 format (2004-02-12T15:19:21+00:00).

string
site.page_list

A list of all available pages.

Traversable
site.page_trail

A trail from the current page up to the root page.

Traversable
site.page_tree

A tree of all available pages.

Traversable
site.route

The requested route, i.e. doc/contents/variables.

string
site.route_params

The requested route params.

array
site.theme

The configured theme.

string
site.time

The current time in ISO-8601 format (2004-02-12T15:19:21+00:00).

string