Home Documentation Templates Examples Showcase GitHub
Theme

Core reference

Page & build metadata values.

$[...] is Nift's general pure value-expression syntax. This page documents the built-in page and build values Nift makes available while processing a tracked file; the names below are the complete built-in metadata set recognised by the current v4 parser.

$[expression]

A metadata lookup such as $[title] is the simplest possible expression. The same brackets can derive values with numeric arithmetic, comparisons, logical operators, parentheses and lazy ternaries:

$[loop.index + 1]
$[price * quantity]
$[score >= 50]
$[published && !draft]
$[featured ? ' featured']

The expression model is the same one used by @if(expression). In $[...] the scalar result is rendered; in @if(...) Nift applies truthiness to that result to choose a branch. Arithmetic is numeric only, logical operators short-circuit, and ternary branches are lazy.

Read the full expressions reference →

Page metadata

SyntaxValue
$[title]The tracked title.
$[name]The tracked name.
$[content-path]The content file path.
$[output-path]The generated output path.
$[template-path]The template file path.

Build metadata

SyntaxValue
$[build-timezone]The build timezone.
$[build-time]The current local build time.
$[build-UTC-time]The current UTC build time.
$[build-date]The current local build date.
$[build-UTC-date]The current UTC build date.
$[build-YYYY]The four-digit build year.
$[build-YY]The two-digit build year.
$[build-OS]The operating system reported for the build.

Metadata names are matched exactly by the parser, including hyphens and capitalisation in names such as build-UTC-time, build-YYYY and build-OS.

Examples

<title>My site — $[title]</title>
<body data-page="$[name]">
  @content
</body>

<small>Built $[build-date] at $[build-time]</small>

Useful while building or debugging

<!-- built from $[content-path] using $[template-path] -->
<!-- output: $[output-path] -->

Comments like these can be handy temporarily when converting a large existing site or checking which tracked item produced a generated file.

Metadata is one value source.

These built-ins can be used directly or inside pure $[...] expressions. JSON bindings, project contracts, loop bindings and pagination metadata provide other values. Pure expressions can derive numeric/boolean results and select lazy ternary branches, but they still cannot assign or mutate template state. See the expressions reference →

Practical examples

Use the tracked title in the document head

<title>$[title] · Nift</title>
<small>Built $[build-date] on $[build-OS]</small>

Leave useful diagnostics while designing a template

<!--
tracked name: $[name]
content:      $[content-path]
template:     $[template-path]
output:       $[output-path]
-->

Those comments can be useful while developing a complicated template hierarchy and removed when you no longer need them.

Local time and UTC

Nift exposes both local and UTC build values so generated metadata can use whichever convention your deployment or content format expects. For example, a human-facing footer might use local build time while machine-oriented generated text uses UTC.