Search code examples
jekyllgithub-pages

Jekyll Folder Structure. Having folders/lists on a page which each have specific posts


I have a page called blog.md which has some code like this.

permalink: /blog/
layout: collection
collection: blog
entries_layout: grid
classes: wide

Then I have a folder called _blog, with a number of .md files in.

Is there anyway I can add another level of order here and instead of displaying all the _blog .md files on the blog.md page.. I want to add two folders/lists which contain certain .md files.

Any ideas? Thanks


Solution

  • This should work by adding the path to your for loop. For example, let's assume you have a directory in your _blog directory called "orange." So your file path would be _blog/orange. To loop through only the files in the orange directory you could do this:

    {% for post in site.blog.orange %}
      {{ post.do-stuff }}
    {% endfor %}
    

    On a side note, Jekyll is going to look for blog posts in the _posts directory. I assume this _blog directory is a collection, but creating a "blog" collection will make things confusing if anyone else ever needs to touch this codebase.