Can I add a post to a collection?

I am working on a journal that has articles from a ton of different authors.

I’d like to create a collection for each author, so readers can view all post by that author.

Can I add the collection, by author name to the front matter of the post and it flow properly?

here is an example that I think does what you want:

I am going to go through this tutorial and provide an update. Thank you, rydar!

Okay, I am a noob so please bear with me…


I don’t understand what “” means? is my site url with .authors at the end of the url?

I don’t understand what “author.url” means?

they made a collection called authors which can be accessed as site.authors.

The dot syntax is a common way of accessing things, you can loop over site.authors and then access the individual items as or author.url etc. Once you start doing it it should make sense.

This is a fairly complex example as it is taking a collection of author data and using some front matter in each post to connect the 2 and do some cool stuff.


The easiest way to do this would instead be to simply add an author field to all of your posts and then loop through posts where matches the author you are referencing.

You would want to include a field called author in the front matter of each post like below:

author: joe-rodgers

and then create a collection called authors.yml inside of your _data folder. This collection could include all of the information pertaining to each of these authors (name, social media links, profession, bio, etc) like so:

  - name: joe-rodgers
    twitter: @joe-rodgers
    bio: Joe is a cool guy
  - name: Author2
    twitter: @notARealPerson
    bio: Author2 isn't as cool

To create a page that lists all of the posts an author has made, you could simply loop through site.posts where author matches the current author. Your end result would be something like this:

{% for author in %}
  {% for post in site.posts | where:"author",{{}} %}
      <a href="{{post.url}}">{{post.title}}</a>
  {% endfor %}
{% endfor %}

This would loop through all the authors, and for each author, create a link for all the posts with their name as the author. See this article for a better explanation:

I have performed the first two steps and can now see an alternative author displayed for a couple posts.

Now I am getting hung up on the last step.

Would love to display a single page that had all the authors listed, and when you selected an author it would take you to a new page that displayed that authors work.

Your step three, do I create a unique page for each author and include the code listed, and do I add my unique author name in the code referenced?

The for loop that I shoed in that third step would display a list of all authors on one page with a sublist of all of their articles below. In terms of creating a separate page for each author, the best option I could think of would be to use a collection instead of a data file.

To implement a collection, you’d basically be creating a folder called _authors in your root directory, defining the collection in your _config.yml, and then creating a .md file for each author.

Defining the collection in your config would look something like this:
- authors

A sample .md file might have all that information that you had in your data file listed in the front matter of each author’s page. Rather than putting actual content in these markdown files, just let them be front matter and allow a layout to loop through all the posts that match that author. I hope that makes sense.