Reputation: 1007
I've created a file called people.yml
inside of the _data
folder. I have a page people.html
where I'm trying to access the information from the data file. It seems like I can only get the info when I create a for loop
. I'm referencing the examples found here to accomplish this. Can't figure out what I'm doing wrong.
people.yml
- id: 123
name: John Does
type: A
people.html
<h1>Person</h1>
<p class="name">{{ site.data.people.name }}</p>
<span class="type">{{ site.data.people.type }}</span>
Upvotes: 0
Views: 166
Reputation: 969
You've made the data in your people.yml file an array by adding the -
. If you want to access it not in a loop, you'll need to remove the hypen.
id: 123
name: John Does
type: A
Then calling {{ site.data.people.name }}
should return "John Does".
Upvotes: 1