Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of referring to authors using Jekyll's _data structures. You can reference the data in a collection in a variety of ways. Line 13 of post.html shows you can: 1. look up a value in the "author" collection relative to a variable defined in the YAML of a page using the layout 2. explicitly naming the data item in code 3. a combination of th…
layout title date author
post
My New Post
2014-01-16 23:05
david

This is my great post with the correct poster.

david:
name: David Hutchison
bio: I am a Software Developer
---
layout: main
---
<article class="post">
{% assign post=page %}
<header>
<h2>
{% if post.date %}<span class="meta">
<time datetime="{{ post.date | date_to_xmlschema }}" pubdate="" data-updated="true" title="{{ post.date | date_to_string }}">{{ post.date | date_to_string }}</time>
</span>{% endif%}
<a href="{{ post.url }}" class="title">{{ post.title }}</a>
</h2>
{% if post.author %}<p>By {{ site.data.author[post.author]['name'] }} / {{ site.data.author.david.name }} / {{ site.data.author[post.author].name }}</p>{% endif %}
</header>
<article>
{{ content }}
</article>
</article>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment