# Can I add a post to a collection?

**URL:** https://talk.jekyllrb.com/t/can-i-add-a-post-to-a-collection/3073
**Category:** Help
**Created:** [July 15, 2019, 4:47pm UTC](https://talk.jekyllrb.com/t/can-i-add-a-post-to-a-collection/3073 "2019-07-15T16:47:30Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![joe-rodgers](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/joe-rodgers/32/2593_2.png) [@joe-rodgers](https://talk.jekyllrb.com/u/joe-rodgers)
#### Post date: [July 15, 2019, 4:47pm UTC](https://talk.jekyllrb.com/t/can-i-add-a-post-to-a-collection/3073/1 "2019-07-15T16:47:30Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)
#### Post date: [July 16, 2019, 1:55am UTC](https://talk.jekyllrb.com/t/can-i-add-a-post-to-a-collection/3073/2 "2019-07-16T01:55:20Z")

</div>

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

> **[Collections](https://jekyllrb.com/docs/step-by-step/09-collections/#list-authors-posts)**
>
> Let’s look at fleshing out authors so each author has their own page with a blurb and the posts they’ve published.

---

<div class="post-metadata">

### Author: ![joe-rodgers](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/joe-rodgers/32/2593_2.png) [@joe-rodgers](https://talk.jekyllrb.com/u/joe-rodgers)
#### Post date: [July 16, 2019, 2:22pm UTC](https://talk.jekyllrb.com/t/can-i-add-a-post-to-a-collection/3073/3 "2019-07-16T14:22:54Z")

</div>

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

---

<div class="post-metadata">

### Author: ![joe-rodgers](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/joe-rodgers/32/2593_2.png) [@joe-rodgers](https://talk.jekyllrb.com/u/joe-rodgers)
#### Post date: [July 16, 2019, 2:37pm UTC](https://talk.jekyllrb.com/t/can-i-add-a-post-to-a-collection/3073/4 "2019-07-16T14:37:48Z")

</div>

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

![structure](https://canada1.discourse-cdn.com/flex030/uploads/jekyllrb/original/2X/6/6a0e9c636136a6ff2c7f6de7cb24ff885bebfb1c.png)

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

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

 ![author%20url](https://canada1.discourse-cdn.com/flex030/uploads/jekyllrb/original/2X/7/7ab7e55995f20bb50f0507a1a8db2bcd7288853f.png)

---

<div class="post-metadata">

### Author: ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)
#### Post date: [July 16, 2019, 2:53pm UTC](https://talk.jekyllrb.com/t/can-i-add-a-post-to-a-collection/3073/5 "2019-07-16T14:53:29Z")

</div>

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 `author.name` 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.

---

<div class="post-metadata">

### Author: ![JacobHelton57](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@JacobHelton57](https://talk.jekyllrb.com/u/JacobHelton57)
#### Post date: [July 16, 2019, 7:01pm UTC](https://talk.jekyllrb.com/t/can-i-add-a-post-to-a-collection/3073/6 "2019-07-16T19:01:15Z")

</div>

Joe,

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 post.author 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:

```
authors:
  - 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 site.data.authors %}
  {% for post in site.posts | where:"author",{{author.name}} %}
      <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: [https://jekyllrb.com/docs/datafiles/#example-accessing-a-specific-author](https://jekyllrb.com/docs/datafiles/#example-accessing-a-specific-author)

---

<div class="post-metadata">

### Author: ![joe-rodgers](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/joe-rodgers/32/2593_2.png) [@joe-rodgers](https://talk.jekyllrb.com/u/joe-rodgers)
#### Post date: [July 16, 2019, 9:04pm UTC](https://talk.jekyllrb.com/t/can-i-add-a-post-to-a-collection/3073/7 "2019-07-16T21:04:40Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![JacobHelton57](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@JacobHelton57](https://talk.jekyllrb.com/u/JacobHelton57)
#### Post date: [July 17, 2019, 7:16pm UTC](https://talk.jekyllrb.com/t/can-i-add-a-post-to-a-collection/3073/8 "2019-07-17T19:16:45Z")

</div>

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](https://jekyllrb.com/docs/collections/) 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:  
collections:  
- 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.
