I have a problem very similar to this one, but unfortunately, the solution doesn't work for me. So I'm posting another question.
I'm making a website with Jekyll and would like to print the information of a yml file on a page or post. Here is a dummy yml file:
- Master student:
- Dummy name1:
- email: blabal@bla.com
- room: 1
- tel: 12345678
- Bachelor student:
- Dummy name:
- email: blabal@bla.com
- room: 12
- tel: 0987654
- Guest:
- Bird:
- email: blabal@bla.com
- room: 10856
- tel: 71864270
This file is placed in a newly made _data
directory, under the name people.yml
. Then, I made a new post on a freshly made site with the minimal theme, which goes as follows:
---
layout: post
title: "Test"
date: 2023-01-12 23:42:09 +0100
---
{% assign people = site.data.people | read_yaml %}
<!-- {{ people }} --> // this tests if the files is loaded or not
{% for role in people %}
{% assign role_data = role[1] %}
{{ role_data[0] }} has the following role: {{ role[0] }}.
{% endfor %}
Once I generate the site, I expect the following text on the post (except maybe for some linebreaks):
Dummy name1 has the following role: Master student
Dummy name has the following role: Bachelor student
Bird has the following role: Guest
Instead, I get this:
has the following role: .
has the following role: .
has the following role: .
that puzzles me. I suspect the reason is the way I access the item values. But can't figure it out. Removing the read_yml
also seems to have no effect.