Data

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

Donate

Become a backer or sponsor to support our work.

Sponsors

Syntax

The function accepts key and page parameters.

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

Parameters

key

NameContextTypeRequiredDefaultSinceExample
key-string---

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

page

NameContextTypeRequiredDefaultSinceExample
page-Page---

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