0

Similar to the question at How to loop through all files in Jekyll's _data folder?, how would one loop through the files in their /_data directory (or a subdirectory) and pull the filenames of each file?

for example, if you had:

_data/
  navigation.yml
  news.yml
  people/
    advisors.yml
    board.yml
    staff.yml

... and you wanted to get the list of files inside /_data/people/?

relizt
  • 375
  • 2
  • 11

1 Answers1

0

If you loop through the subdirectory, each for item (in this case "file") will have file[0] as the filename (without the extension) and file[1] as the content of the file.

Thus, your code can look like:

{% for file in site.data.people %}
  {{ file[0] }}
{% endfor %}

would result in:

advisors
board
staff
relizt
  • 375
  • 2
  • 11