Data files

Data files are like having a database on your site

Data files are a powerful feature, that allow you to avoid repetition and allow you to store configuration and make your templates and pages more flexible.

Data folder

Data files need to go into the _data folder for soverin sites to use them. These files must be YAML, JSON, or CSV files (using either the .yml, .yaml, .json or .csv extension), and they will be accessible via

Example: a list of photos

Say you want to have a list of photos, their thumbnails and some text on a page. You could add this in markdown or HTML, but this becomes repetitive really soon. What you can do instead is add a _data/photos.yml :

yaml - photo: dad.png thumbnail: dad_thumb.png title: Picture of dad and me - photo: mom.png thumbnail: mom_dad_thumb.png title: Picture of mom and dad - photo: sis.png thumbnail: sis_thumb.png title: Picture of my sis and me

This data file is available in your pages/posts and templates as and you can then use it to display a list of photos:

html <ul> {%for photo in} <li> <a href="{{}}" title="{{photo.title}}"> <img src="{{photo.thumbnail}}" /> </a> </li> {%endfor%} </ul>

Related Docs