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 ( |
string |
| page.categories | One or more categories that belong to the page. |
string[] |
| page.content_type | Content-Type of the HTTP response. Defaults to |
string |
| page.created | Creation time of the page. Not set automatically; valid values are formatted as ISO 8601 ( |
string |
| page.date | Date of the page. Set explicitly, taken from a date prefix in the file name ( |
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 |
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 |
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 |
string |
| page.menu_title | Title used in navigation elements like menu, sitemap, or breadcrumb. When read and empty, it falls back to |
string |
| page.modified | Modification time of the page as an ISO 8601 ( |
string |
| page.parent_id | Aliased parent page ID, for example |
string |
| page.parent_route | Parent route of the page, for example |
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 |
string|array |
| page.route | Route of the page, for example |
string |
| page.segments | Page content as an associative array of segments (including |
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 |
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. |
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 |