How to access a specific item in the data folder

It's common to want to access a specific item in the data folder. this should be documented.
This commit is contained in:
David Silva Smith 2015-02-15 16:32:40 -05:00
parent fa6981fb8c
commit ac7c1d0cd6
1 changed files with 27 additions and 0 deletions

View File

@ -114,3 +114,30 @@ The organizations can then be accessed via `site.data.orgs`, followed by the fil
</ul>
{% endraw %}
{% endhighlight %}
## Example: Accessing a specific author
Pages and posts can also access a specific item. The example below shows how to access a specific item:
'_data/peoplejekyll.yml':
{% highlight yaml %}
dave:
name: David Smith
link: /bitcoin-expert/
twitter: DavidSilvaSmith
{% endhighlight %}
The author can then be specified as a page variable in a post's frontmatter:
{% highlight html %}
{% raw %}
---
title: sample post
author: dave
---
{% assign author = site.data.people.[page.author] %}
<a rel="author" href="{{ author.twitter }}" title="{{ author.name }}">author.name</a>
{% endraw %}
{% endhighlight %}