Functions

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.

FunctionDescription
breadcrumbsCreates a breadcrumb trail to the current page.
filelistConfigures the filelist collection.
imgPlaces a resized or cropped image.
navCreates a navigation for the children of a given page.
navChildrenCreates a navigation for the children of the current page.
navSiblingsCreates a navigation for the siblings of the current page.
navTopCreates a navigation for the first level of pages.
navTreeCreates a nested navigation tree.
newPagelistResets and configures the pagelist collection.
pagelistUpdates the configuration of the current pagelist.
queryStringMergeMerges key/value pairs with the current query string.
redirectRedirects to another URL.
setDefines 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:

  1. Snippets
  2. Built-in functions
  3. Custom functions
  4. 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.

ucwords breadcrumbs