Data

Function to reading JSON, TOML, YAML data from page resources and site data.

Syntax

The function accepts key and page parameters.

1{{ with partial "base/functions/data" (dict "key" "foobar" "page" .) }}
2  {{/* ... */}}
3{{ end }}

Parameters

key

NameTypeRequiredDefaultSince
keystring--

The name of data file without extension, dot (.) represents the path seperator.

page

NameTypeRequiredDefaultSince
pagePage--

The current page variable.

Data Files Lookup Order

Let’s take content/example/index.md page as an example, assume the key is foo.bar.

Path
/content/example/foo/bar.toml
/content/example/foo/bar.yaml
/content/example/foo/bar.yml
/content/example/foo/bar.json
/data/foo/bar.toml
/data/foo/bar.yaml
/data/foo/bar.yml
/data/foo/bar.json