I’ve been using .json in connexion with the data dir to manage small info I need for my website like social links for exemple. I’ve been willing to switch to yaml since the beginning because it’s easier to write, read and maintain (not so sure now).
But I cannot figure out a way to do this proper:
I used this online converter to make sure I did this right. That is the content of /data/socials.yaml which I retrieve with .Site.Data.socials :
Haven’t tried, but I am almost sure that you need a “parent key” in the data files. So if you put that whole YAML structure under a parent key foo:, you should be then able to access your data with .Site.Data.Socials.foo.
I supposed that you omitted the parent on your code, so that’s why I didn’t mention it. It’s required AFAIK.
I have a media.yaml file with:
files:
- file: BL_circlelogo_color_CMYK.eps
title: 'Primary logo'
description: 'The Brightline Initiative logo calls attention with its boldness. Tapered circular strokes connect the two I’s in the Brightline word mark.
The primary logo should be used whenever possible.'
- file: BL_circlelogo_black_1C.eps
title: 'Primary logo – Black and White'
description: 'One-color version of the Brightline Initiative primary logo available for circumstances when it is not possible to use the primary color version.'
And I range them using:
{{ range .Site.Data.media.files }}
{{.title}}
{{.description}}
and so on
{{ end }}