AiiDee AiiDee - 3 years ago 153
Markdown Question

Is it possible to loop over subfolders in Jekyll?

I'm currently trying to loop over a subfolder in Jekyll but I don't know whether this is possible.

My folder structure looks like this:


For example, I want to reach folder_1 by a loop how can I do this?

{% for page in pages.folder_1 %}


{% endfor %}

What I want is that I've a static page and on this page I want to display the title and the description of each page in one of the subfolders.

Could you please help me?

Answer Source

Avoid naming main folder with an underscore unless you are using the _posts folder.

Then filter posts or pages checking their path:

{% assign folder1 = site.pages | where_exp: "item" , "item.path contains 'folder1'"%}
{% for item in folder1 %}
{% endfor %}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download