Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Author archive pages in Jekyll

Tags:

ruby

jekyll

I'm trying to make a multiple author blog with Jekyll on Github pages. I added authors array field to _config.yml and I can use that data on posts template.

_config.yml:

authors:
    muratcorlu:
        display_name: Murat Corlu
        avatar: 2906955ae59c795275979d3782d7bfca

posts.html

{% assign author = site.authors[page.author] %}

<p>Author: {{ author.display_name }}</p>

Now I want to make an author archive page with a url like /authors/muratcorlu/ (i.e. listing posts authored by muratcorlu), but I don't know how can I get author name from url.

like image 565
Murat Çorlu Avatar asked Jan 27 '12 00:01

Murat Çorlu


1 Answers

I'm afraid you can't create those pages automatically. If you have 5 authors, you will have to create 5 pages manually. The pages can use the same layout, so it will not be very painful.

This would be authors/muratcorlu.textile

---
layout: author
author: muratcorlu
---

You would have to create each of those manually. Fortunately, you don't have to do anything else - the rest can be put in a shared layout that can look like this:

<ul>
{% for p in site.pages do %}
  {% if p.author == page.author %}
    <li><a href="{{ p.url }}">{{ p.title }}</a></li>
  {% endif %}
{% endfor %}
</ul>
like image 152
kikito Avatar answered Oct 18 '22 09:10

kikito