Is there a good lad or lass out there who can help me see where my Liquid syntax is incorrect? I want to make a staff directory from a yaml file named staff.yml and it is in a _data directory. My default page w/ {{ content }} is correct and I’ve got {% include staff.html %} in the staff.md file.
My YML file is valid:
—
names:
-
Name: her name
Position: not boss
Email: her@email.com
EXT: Ext. 105
-
Name: his name
Position: not boss
Email: him@email.com
EXT: Ext. 104
-
20 more entries
Thank you v much for your suggestion and link. You got me on the right track. The solution was to use the arbitrary but singular tense ‘name’, not plural ‘names’. This is the correct html:
<tbody>
{% for name in site.data.staff %}
<tr>
<td>{{ name.Name }}</td>
<td>{{ name.Position }}</td>
<td>{{ name.Email }}</td>
<td>{{ name.EXT }}</td>
</tr>
{% endfor %}
</tbody>
just an fyi - it does not matter what you call that particular part - names or name, or item or x, as long as you reference it in the code the same it will work.
I use item as the identifier in the loop - so for item in that-thing and then you use item.name, item.date etc
I find item to be more obvious that it is the loop item, not a name or post or whatever. When learning jekyll originally I would see examples of loops with post as the identifier (not sure what that is called) and it clearly led to people like me thinking that post.name, post.date etc were actual things - but they only exist within the loop.