Page Properties

Any file that contains a page properties block as known as front matter is considered a valid page by Herbie. The page properties block must be at the beginning of the file. There must be valid YAML between two lines of three hyphens. This sounds a bit complicated, but it is quite simple. Here is an example for a page properties block:

---
title: Get started with your own website
layout: default.html
---

Predefined variables (see reference below) or custom variables can be used as page properties. These variables are available in all layout and content files as page variables. Here is an example:

{{ page.title }}
{{ page.layout }}

Predefined variables

There are some predefined and reserved variables that are used by the system. These can be assigned a value in the page properties block of a page.

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 @page/2-company/3-about-us.md.

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 site/themes/.

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 @page/2-company/1-index.md

string
page.parent_route

The parent route of the page like company.

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 company/about-us.

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

Custom variables

Any custom variable in the page properties block that is not predefined will be automatically recognized by Herbie and made available in the layout files and page content. For example, if you declare a variable class, you can retrieve it in the layout file and use it to set a CSS class.

In the page properties you declare the value of the variable:

---
title: Welcome to my website!
class: home
---

In the page content itself, you can access these variables as follows:

{{ page.title }}
{{ page.layout }}

And in layout files you output the variables the same:

<!DOCTYPE HTML>
<html>
<head>
    <title>{{ page.title }}</title>
</head>
<body class="{{ page.class }}">
    ...
</body>
</html>

This allows page variables to be used and enriched with additional custom variables of your choice.