# List collections items in the layout

**URL:** <https://talk.jekyllrb.com/t/list-collections-items-in-the-layout/3365>\
**Category:** Help\
**Created:** [September 18, 2019, 11:25am UTC](https://talk.jekyllrb.com/t/list-collections-items-in-the-layout/3365 "2019-09-18T11:25:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JulSeb42](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/julseb42/32/2232_2.png) [@JulSeb42](https://talk.jekyllrb.com/u/JulSeb42)\
**Post date:** [September 18, 2019, 11:25am UTC](https://talk.jekyllrb.com/t/list-collections-items-in-the-layout/3365/1 "2019-09-18T11:25:59Z")

</div>

Hi,

I’m trying to display a list of items from collections on a website. I’d like to use one layout and write in the front matter the name of the category so it displays in the page the name and URL of every pages belonging to this collection.

This is my code at the moment:

```auto
 {% for collection_name in site.collection_names %}
<li>
   <a href="{{ collection_name.url }}" class="btn btn-full btn-primary">{{ collection_name.title }}</a>
</li>
{% endfor %}

```

Does someone have a solution?

I’m using Jekyll 3.8.5, and due to Github Pages plugin I can’t use Jekyll 4.0 for now.

Thanks!

---

<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:** [September 18, 2019, 3:45pm UTC](https://talk.jekyllrb.com/t/list-collections-items-in-the-layout/3365/2 "2019-09-18T15:45:17Z")

</div>

collection\_names is the actual name of the collection?

What happens when you run that? nothing? are you sure you have collections setup correctly? are they outputting to where you told them to (if you have output true).

A little more info like what you have in your config and what is in the collection would be good. Link to repo even better.

---

<div class="post-metadata">

**Author:** ![JulSeb42](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/julseb42/32/2232_2.png) [@JulSeb42](https://talk.jekyllrb.com/u/JulSeb42)\
**Post date:** [September 18, 2019, 4:00pm UTC](https://talk.jekyllrb.com/t/list-collections-items-in-the-layout/3365/3 "2019-09-18T16:00:43Z")

</div>

No collection\_name is just an example.  
This works, but I have to put it in every category list pages with replacing the name of the category. The config file is good, everything set to output: true. I tried to do it like this:

```auto
{% for {{page.collection_name}} in site.{{page.collection_name}}s %}

```

but of course it didn’t work.

This is the link to the repo: [https://github.com/fajny-css/fajny-css.github.io](https://github.com/fajny-css/fajny-css.github.io)

---

<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:** [September 18, 2019, 5:19pm UTC](https://talk.jekyllrb.com/t/list-collections-items-in-the-layout/3365/4 "2019-09-18T17:19:44Z")

</div>

you can’t do it like that - the word after `For` is the iterator (?) and is just a word - I prefer `item` as it makes it more clear what it is.

I think you need to do a where in the second part or maybe do an assign with a where first to limit the set, then iterate of the limited set.
