From ac7c1d0cd64e32df42209e399f6ee6bf95aba434 Mon Sep 17 00:00:00 2001 From: David Silva Smith Date: Sun, 15 Feb 2015 16:32:40 -0500 Subject: [PATCH] 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. --- site/_docs/datafiles.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/site/_docs/datafiles.md b/site/_docs/datafiles.md index 7f54a279..5a5de195 100644 --- a/site/_docs/datafiles.md +++ b/site/_docs/datafiles.md @@ -114,3 +114,30 @@ The organizations can then be accessed via `site.data.orgs`, followed by the fil {% 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] %} + + +{% endraw %} +{% endhighlight %}