10

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.

ajcw
  • 23,604
  • 6
  • 30
  • 47
Murat Çorlu
  • 8,207
  • 5
  • 53
  • 78
  • Hey, you might be interested in [jekyll-auto-authors](https://github.com/gouravkhunger/jekyll-auto-authors) plugin that I recently created to generate automatic paginated archives for authors, similar to what you desire. Here's [my answer](https://stackoverflow.com/a/71823795/9819031) that explains how to use it. – Gourav Oct 20 '22 at 07:35

1 Answers1

8

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>
kikito
  • 51,734
  • 32
  • 149
  • 189
  • Nicely done, this is pretty useful. I had to change `site.pages` and `page.author` to `site.posts` and `post.author` to get it to show the blog articles that each author had written. – Lenwood Jun 29 '13 at 13:20
  • 1
    Hi! Automatic author page generation is now possible with my plugin [jekyll-auto-authors](https://github.com/gouravkhunger/jekyll-auto-authors) – Gourav Oct 20 '22 at 07:36