Docs (Public)

Data files allow storing arbitrary data which is not tied to any specific page. Data files are stored inside the data folder and can be in JSON or YAML format with .json or .yaml/.yml extensions respectively.

The name of the data file, excluding its extension, is used as accessor key on the site.data object and holds the actual data.

Data files can be nested inside subfolders. Every subfolder will create additional accessor on top of the previous one.

Example:

.
├── layouts
├── components
├── content
├── data
│   ├── more
│   │   └── info.yaml
│   ├── header.json
│   └── footer.yml
├── static
└── config.yml

header.json

{
  "title": "Stackbit",
  "intro": "Hello World"
}

footer.yml

links:
  - url: https://www.stackbit.com
    label: Stackbit
  - url: https://www.example.com
    label: Example

more/info.yaml

message: Thank you!

header.html

<header>
  <h1>{{ site.data.header.title }}</h1>
  <p>{{ site.data.header.intro }}</p>
</header>

footer.html

<footer>
  <div>{{ site.data.more.info.message }}</div>
  <ul>
    {% for item in site.data.footer.links %}
      <li><a href="{{ item.url }}">{{ item.label }}</a></li>
    {% endfor %}
  </ul>
</footer>