[SOLVED] Listing pages of a collection


I had a bizarre and large draft here about how to interpret the documentation page concerning collections that I’ve been feeding the last four days… but that was deleted and I’ll try to limit this topic to the problem I’m facing: collections not working as expected (after reading - again and again - the documentation).

Desired result.

1 - A directory to the custom collections
2 - each collection’s directory should start with an _ (underscore)
3 - loop through and list the files of a collection in a page of another collection

1 - Added the following to _config.yml:

  collections_dir: _collections

2 - Somehow Jekyll wouldn’t build anything inside a directory prefixed with an underscore, at least until they were “included” as following:

include: ['_collections', '_pages', '_projects']

_collections: the directory to keep collections organized.
_pages: the place to static general pages (like “about”, “contact”, listing categories etc).
_projects: a collection with pages that just don’t match the general purpose of _pages.

3 - I cannot get a list of the files (title and url) inside _projects. All pages exists. In the _config.yml, the permalink is set as:

permalink:        :slug/

And all pages have something like this in their front-matter:

permalink: /manually-added-slug/

All pages can be acceded as http://localhost:4000/manually-added-slug/. This was the only way I founded to solve the permalink issue.

Basically, inside _collections/_pages/projects.md, I’m trying to get something like this to work:

{% for project in site.projects %}
      <a href={{ project.path }}">- {{ project.name }}<a/>
  {% endfor %}

But keeping in mind that that is just an example… since many different things were tried there without success. :wink:

That’s with Jekyll 3.6.0 (but not declared in the Gemfile), in Archlinux with Bundler version 1.15.4.
And just for the sake of… well… here is the gem file content:

source "https://rubygems.org"

Thanks in advance for any given direction. :smiley:


I think your issue is how you’re naming the collections and configuring them in your _config.yml.

I haven’t used the new feature that allows you specify a collections dir, but from your example above for projects… projects.md isn’t technically a collection, it’s a document in a _pages collection.

If you want a “projects” collection then it needs to be _collections/_projects/whatever.md. Then you’ll be able to access the documents inside of it with site.projects. That is if you’ve also configured them to output:

    output: true
    permalink: # your permalink structure eg. /:collection/:path/

Collections need to be named with an _ underscore, be in the root of your project (or in another folder if you’re using collections_dir).


Hey @mmistakes, as always, thank you!

I think your issue is how you’re naming the collections and configuring them in your _config.yml.

Good point, I feel that I’m missing and overdoing something here.

I did tried your suggestion, but without luck.

Most of the resources concerning this I’ve found mention the permalink:, but I don’t understand why, since I’m setting it globally in the config. And another issue is, why is it necessary to first include the repositories prefixed with underscore? AFAIK, they should not be ignored

Thanks anyway. (:


@lsrdg configuring collection_dir is not available in 3.6.0. Its slated for v3.7.0

The online documentation at jekyllrb.com is at times way ahead of time…(mirroring the master branch) and not particularly aligned to the latest public release.
I agree this is an issue… but that’s for another time…

Output: true for all collections

Thanks, @ashmaroli! And no worries, I’ve decided to use that just because it was an interesting idea, and I’m glad it will come with 3.0.7.

Anyway, I still don’t understand why I can’t a list of files inside a folder (a collection folder), despite of moving the collections back to the root of the project(?), and why do the repositories prefixed with an underscore need to be include:ed.

Should I maybe define the path on the defaults: (and scope and values etc…)?


how does your current collections configuration look like…? (you can use dummy names for privacy)


The lines of _config.yml concerning collections as after trying @mmistakes idea:

permalink:        :slug/

include: ['_pages', '_projects']

    output: true
    permalink: :slug/
    output: true
    permalink: :slug/

I tried with and without those fields, combining them, omitting some of them etc. (:


omit the trailing underscore in your collection configuration, and be mindful of the indentation (no tabs only spaces, in multiples of two)

permalink:        :slug/

# not required..
# include: ['_pages', '_projects']

    output: true
    permalink: :slug/
    output: true
    permalink: :slug/



It’s done! Topic marked as “solved”. Thanks, @ashmaroli for helping here!

Apparently, when I tried to set it that way, my collections were inside the collections_dir: and wouldn’t work anyway. Despite of that, my indentation was broken on its second level, and I won’t even mention the html syntax erros that became evident after I got the list outputted.

Thanks again to @mmistakes and @ashmaroli for taking the time and for all the questions I’ve never asked simply because you guys have already answered them somewhere else. (: