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 }}
{{ 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
Variable | Description | Type |
---|---|---|
page.authors |
One or more authors of the page |
string[] |
page.cached |
If set the page is cached (depending if caching is active) |
bool |
page.cache_id |
The cache ID used for identifying when caching (read-only) |
string |
page.categories |
One or more categories, that belongs to the page |
string[] |
page.content_type |
The Content-Type of the page for the HTTP response, automatically set by Herbie. |
string |
page.created |
The creation time of the page. This value is not set automatically. |
string |
page.date |
The date of the page. The modification date or an explicitly set date. |
string |
page.excerpt |
The excerpt of the page body. |
string |
page.format |
The formatter like markdown or textile. Is set automatically depending on the file extension. |
string |
page.hidden |
If set the page is not visible in navigation elements like sitemap or breadcrumb. |
bool |
page.id |
The aliased ID of the page like |
string |
page.keep_extension |
If true the file extension is used for urls. Useful for xml pages like sitemap for search engines. |
bool |
page.layout |
The layout as basename (without file extension). Layout files are located in folder |
string |
page.menu_title |
The title for menu elements like sitemap or breadcrumb. If empty the page title will be shown. |
string |
page.modified |
The modification time of the page as ISO 8601 formatted string. This value is set automatically. |
string |
page.parent_id |
The aliased parent ID of the page like |
string |
page.parent_route |
The parent route of the page like |
string |
page.path |
The path to the page file, set per default. |
string |
page.redirect |
If set the request will be redirected to the given page. |
string|array |
page.route |
The route of the page like |
string |
page.segments |
The page content as associative key value array. The content is lazy loaded and not available until this member variable is accessed. |
array |
page.tags |
One or more tags that belongs to the page. |
string[] |
page.title |
The title of the page. |
string |
page.twig |
If set the page will be parsed by the Twig Renderer first (default: true). |
bool |
page.type |
The page type (default: page). |
string |
page.<name> |
Any numbers of custom variables. |
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) |
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 to, 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 |