# Looping over filenames in template

**URL:** <https://zola.discourse.group/t/looping-over-filenames-in-template/1929>\
**Category:** Uncategorized\
**Created:** [November 9, 2023, 6:19pm UTC](https://zola.discourse.group/t/looping-over-filenames-in-template/1929 "2023-11-09T18:19:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MindsForge](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@MindsForge](https://zola.discourse.group/u/MindsForge)\
**Post date:** [November 9, 2023, 6:19pm UTC](https://zola.discourse.group/t/looping-over-filenames-in-template/1929/1 "2023-11-09T18:19:49Z")

</div>

I’m working on a site that displays links to media files and I’ve been using a bash script to generate the `_index.md` file with an array of filenames which is used to generate the links in the template file. Is this the best way or is there a way for Zola to loop over a directory of filenames without needing the script? I don’t have the files in the Zola project because I have a separate subdomain setup with caching for the media files. Thanks!

---

<div class="post-metadata">

**Author:** ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)\
**Post date:** [November 9, 2023, 8:57pm UTC](https://zola.discourse.group/t/looping-over-filenames-in-template/1929/2 "2023-11-09T20:57:27Z")

</div>

If you have a list of files, you could use the `load_data` function to read it, assuming you can have it in a supported format: [Overview | Zola](https://www.getzola.org/documentation/templates/overview/#load-data)
