Trying to parse data file, Hugo is silent

Thanks a lot @Mikhail and @HeyOzRamos, both your solutions work.

To sum up, if anyone is stumbling upon this thread, here’s how my data is structured:

/data/projects.yml
/content/projects/_index.md
/layouts/section/projects.html

Solution1:

<!-- /layouts/section/projects.html  -->
{{ range .Site.Data.projects }}
    {{ .name }}
{{ end }}

Works with this projects.yml file:

# /data/projects.yml
1:
  name: My awesome project
  type: Corporate website
2:
  name: My super duper project
  type: Corporate website

Solution 2:

<!-- /layouts/section/projects.html -->
{{ range .Site.Data.projects.projects }}
    {{ .name }}
{{ end }}

Works with this projects.yml file:

# /data/projects.yml
projects:
    - name: My awesome project
      type: Corporate website
    - name: My super duper project
      type: Corporate website

It’s a bummer that it wouldn’t work with my original file, as it’s a valid yml file and Hugo gave me no error, but I’m glad I’ve found a solution thanks to you guys.

4 Likes