Template functions · Content
data
Load and parse a JSON file from the data directory.
data "file.json"Reads data/<file> and returns the parsed JSON: an object becomes a map you read with .key, an array becomes a list you can range, sort and filter. If the file is missing or invalid, the error is logged and the result is empty.
A page that calls data is rebuilt whenever content changes during -serve.
Example
{{ $site := data "site.json" }}
<title>{{ $site.title }}</title>
{{ range data "links.json" }}
<a href="{{ path .path }}">{{ .name }}</a>
{{ end }}Other functions
sources
sort
filter
limit
offset
select
paginate
pages
page
path
hash
json
contains
html
js
css