我如何使用 Jekyll 在子文件夹中循环

How can i loop in a subfolder with Jekyll

我目前正在使用 jekyll,我有一个名为 "articles" 的文件夹,它位于我的项目的根目录中。

在此文件夹中,我有 2 个名为 "fr" 和 "eng" 的子文件夹。

我的目标是在一页的 "fr" 文件夹中循环,在另一页的 "eng" 文件夹中循环。

我试过{% for this in site.articles.fr %}但是没用。

我也试过{% assign folder1 = site.articles | where_exp: "this" , "this.path contains 'folder1'"%} {% for this in folder1 %},但也没用。

还有其他方法吗?

我会将 'articles' 重命名为“_posts”以遵循 Jekyll 标准。

然后可以像这样过滤“_posts”中的文件夹:

{% for post in site.posts %}
  {% if post.path contains '/fr/' %}
    ..your code
  {% endif %}
{% endfor %}