Functions provide a collection of essential tools for templates. While some of them are just convenient shorthands for more complex statements, others provide the main interface to configure collections, create redirects, work with query strings or define variables during runtime.
<@ function { options } @>
Options
Like all statements, functions are always wrapped in statement delimiters. Options are passed as a kind of relaxed JSON object, where keys don't need to be quoted. Variables can be used as values as well. They only need to be quoted when they are combined with other strings.
<@ function {
key: @{ variable },
anotherKey: "@{ variable } in a string",
number: 10,
flag: true
} @>
Values that are passed as variables can of course also be modified using filters. A common use case is defining defaults for query string parameters:
<@ pagelist { page: @{ ?page | def (1) } } @>
Functions that don't require any options can be called without the options object:
<@ navTop @>
Available Functions
The following functions are available out of the box. Follow the links for a detailed description of their options and some examples.
| Function | Description |
|---|---|
| breadcrumbs | Creates a breadcrumb trail to the current page. |
| filelist | Configures the filelist collection. |
| img | Places a resized or cropped image. |
| nav | Creates a navigation for the children of a given page. |
| navChildren | Creates a navigation for the children of the current page. |
| navSiblings | Creates a navigation for the siblings of the current page. |
| navTop | Creates a navigation for the first level of pages. |
| navTree | Creates a nested navigation tree. |
| newPagelist | Resets and configures the pagelist collection. |
| pagelist | Updates the configuration of the current pagelist. |
| queryStringMerge | Merges key/value pairs with the current query string. |
| redirect | Redirects to another URL. |
| set | Defines shared or session variables during runtime. |
Precedence
Functions share the statement syntax with snippets, custom functions and extensions. When a statement is called, Automad looks for a matching implementation in the following order:
- Snippets
- Built-in functions
- Custom functions
- Extensions
Extending Functions
In case you need functionality that is not covered by the built-in functions, you can quickly add your own custom functions within a theme or create a reusable extension package.