Reputation: 3555
I am working on a Jekyll site on and I want to be able to have a page for each person in the group. I know I can use a collections to generate pages, if the files in the collection are markdown. I want to be able to have yaml files in the collection, then generate pages after passing each yaml file to a template.
People files might look like this:
# person-1.yaml
name: thingy m. bob
position: coffee fetcher
bio: no bio needed
# person-2.yaml
name: mars e. pan
position: head honcho
bio: expert in everything
Then a template file like this (people-template.md):
# {{ page.name }} - {{ page.position }}
{{ page.bio }}
And the output would be individual file under /people/
, i.e, /people/person-1
, /people/person-2
, which are formatted as in the template, but using the .yaml
files.
I am using GitHub pages, so I don't want to have to use any plugins which that doesn't support.
Upvotes: 3
Views: 1835
Reputation: 6171
I have implemented something similar ... this is the setup I created:
- _Layouts
- person.html
...
people
- index.md (list of people - see code below)
- _posts
- 2015-01-01-person-one.md (ordering defined by date which is thrown away)
- 2015-01-02-person-two.md
- 2015-01-03-person-three.md
...
Then for a list of people you can use something like:
<ul>
{% for person in site.categories.people %}
<li><a href="{{ person.url }}>{{ person.name}}"></a></li>
{% endfor %}
</ul>
with each person being in the form
---
name: "thingy m. bob"
# using quotes to avoid issues with non-alpha characters
position: "coffee fetcher"
bio: "no bio needed"
layout: person
---
any markdown if you want more of a description
I hope that has given you something to start with ... I think that putting the _posts
folder under the people
folder will automatically set the category to people
. If I am wrong, just add category: people
to the yaml.
You can set the pattern for the post urls in _config.yaml if you want to remove the date part.
Good luck
Upvotes: 1