{% assign entries = site.pages | sort: "dir" %} {% capture folders_capture %}{% for entry in entries %}{% if entry.dir != "/" %}{% assign level = entry.dir |split: "/" |size %}{% if level < 3 %}{% assign slug = entry.dir | remove: "/" %}{% assign folder = slug %}{{ folder }}^{% endif %}{% endif %}{% endfor %}{% endcapture %} {% assign folders = folders_capture | split: "^" |uniq %}