# Using jekyll postfiles plugin for collections

**URL:** https://talk.jekyllrb.com/t/using-jekyll-postfiles-plugin-for-collections/1038
**Category:** Help
**Created:** [October 2, 2017, 12:02pm UTC](https://talk.jekyllrb.com/t/using-jekyll-postfiles-plugin-for-collections/1038 "2017-10-02T12:02:12Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![hnaseri](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/hnaseri/32/831_2.png) [@hnaseri](https://talk.jekyllrb.com/u/hnaseri)
#### Post date: [October 2, 2017, 12:02pm UTC](https://talk.jekyllrb.com/t/using-jekyll-postfiles-plugin-for-collections/1038/1 "2017-10-02T12:02:12Z")

</div>

I’m using a plugin named [jekyll postfiles](https://github.com/nhoizey/jekyll-postfiles) to handle assets beside my docs. The problem is that this plugin currently only supports posts. And I want to also use the same approach for my collections. With a little research I found that posts are also a kind of collection. And all posts and collection docs can be accessed by

```
`site.collections`

```

which is organized in the following manner:

```auto
{
  "posts" => # < Jekyll::Collection @label = posts docs = [All Posts are here] > , "myfirstcollection" => # < Jekyll::Collection @label = myfirstcollection docs = [All myfirstcollection docs are here] >
}

```

I realize that in this plugin, there is a loop to iterate all post docs :

```
  site.posts.docs.each do |post|
    copy_post_files(post)
  end

```

Now I think with a little tweak here we can also handle collection docs. However I have no experience with ruby and I don’t know what to do.

any Idea?

---

<div class="post-metadata">

### Author: ![Frank](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/frank/32/26_2.png) [@Frank](https://talk.jekyllrb.com/u/Frank)
#### Post date: [October 15, 2017, 12:02pm UTC](https://talk.jekyllrb.com/t/using-jekyll-postfiles-plugin-for-collections/1038/2 "2017-10-15T12:02:07Z")

</div>

Given that you have a `copy_collection_files` function defined, you can to the same accessing `site.collections.docs`

```ruby
site.collections.docs.each do | collection |
 copy_collection_files(collection)
end

```

---

<div class="post-metadata">

### Author: ![hnaseri](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/hnaseri/32/831_2.png) [@hnaseri](https://talk.jekyllrb.com/u/hnaseri)
#### Post date: [October 23, 2017, 9:16am UTC](https://talk.jekyllrb.com/t/using-jekyll-postfiles-plugin-for-collections/1038/3 "2017-10-23T09:16:16Z")

</div>

Yes. I already have done it and its working. However there is still a problem that I discussed [here](https://github.com/jekyll/jekyll/issues/6410). The problem is that jekyll core also transfer collection files, but to a diffrent place. And now I have too many duplicate files in my website.

---

<div class="post-metadata">

### Author: ![CraigChamberlain](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/craigchamberlain/32/2703_2.png) [@CraigChamberlain](https://talk.jekyllrb.com/u/CraigChamberlain)
#### Post date: [July 25, 2020, 2:59pm UTC](https://talk.jekyllrb.com/t/using-jekyll-postfiles-plugin-for-collections/1038/4 "2020-07-25T14:59:36Z")

</div>

Hi hnaseri, maybe too late to reply but I think you can set collections to not automatically generate pages in the \_config.yml file.

I’ve been trying to access collections from a plugin.You post has given me an idea.
