# Obtaining a list of files in a static folder without an index?

**URL:** <https://zola.discourse.group/t/obtaining-a-list-of-files-in-a-static-folder-without-an-index/2951>\
**Category:** Uncategorized\
**Created:** [July 28, 2026, 4:05pm UTC](https://zola.discourse.group/t/obtaining-a-list-of-files-in-a-static-folder-without-an-index/2951 "2026-07-28T16:05:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthillco](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/matthillco/32/869_2.png) [@matthillco](https://zola.discourse.group/u/matthillco)\
**Post date:** [July 28, 2026, 4:05pm UTC](https://zola.discourse.group/t/obtaining-a-list-of-files-in-a-static-folder-without-an-index/2951/1 "2026-07-28T16:05:42Z")

</div>

I know that I can loop through colocated assets by interrogating `section.assets` or `page.assets`.

However, I’m working on a project that collects related images into their own static folders and I’m trying to obtain that list of images without needing an associated index file.

Is it currently possible in Zola to get a list of files from an arbitrary folder?

---

<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:** [July 30, 2026, 6:37pm UTC](https://zola.discourse.group/t/obtaining-a-list-of-files-in-a-static-folder-without-an-index/2951/2 "2026-07-30T18:37:13Z")

</div>

Not currently no

---

<div class="post-metadata">

**Author:** ![matthillco](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/matthillco/32/869_2.png) [@matthillco](https://zola.discourse.group/u/matthillco)\
**Post date:** [August 3, 2026, 9:16am UTC](https://zola.discourse.group/t/obtaining-a-list-of-files-in-a-static-folder-without-an-index/2951/3 "2026-08-03T09:16:20Z")

</div>

OK, thanks for the reply. Next question then: could Zola support this in the future? It would be an extremely useful feature to interrogate arbitrary folders (although I understand there could be context, security or os-level considerations).

EDIT: Looks like this request was previously made here:

> [@New global functions \`get\_files\` or similar](https://zola.discourse.group/t/new-global-functions-get-files-or-similar/307):
>
> Sometimes it’s useful to iterate over files to use them in templates. You can do this using page.assets, but this does not include files that are not colocated with that page. We could have a get\_files(path=\<some path\>) that returns a list of files in path. Optionally we could make that recursive. Additionally, it would be useful for get\_files to accept some glob, for example get\_files(path=\<some\_path\>, glob="\*.jpg"), because otherwise looping over the returned vector might be a big cumbersome…

---

<div class="post-metadata">

**Author:** ![Colas.Nahaboo](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/colas.nahaboo/32/1610_2.png) [@Colas.Nahaboo](https://zola.discourse.group/u/Colas.Nahaboo)\
**Post date:** [August 3, 2026, 4:33pm UTC](https://zola.discourse.group/t/obtaining-a-list-of-files-in-a-static-folder-without-an-index/2951/4 "2026-08-03T16:33:05Z")

</div>

By looking at this issue, I realized that Zola has a way to actually iterate on a dynamically-created list of files: dynamically load the list from an URL.

This is not a direct answer to your question, but I guess it is a way to implement a workaround today in a somewhat forward-compatible way with possible future native Zola implementations.

All you need to do is to have a small local web server with a CGI script returning the list of files as a JSON list.  
E.g:

```auto
[
"icon/colas-avatar-32.png",
"icon/colas-avatar-64.png",
"icon/colas-avatar-128.png",
"icon/colas-avatar-256.png"
]

```

A shortcode template can then be test\_assets.html:

```auto
{% set images = load_data(url=url, format="json") %}

<div class="gallery">
  {% for img in images %}
    <img src="{{ get_url(path=img) }}" alt="Asset Image" loading="lazy">
  {% endfor %}
</div>

```

That you would use in a topic as:

`{{ test_assets(url="http://localhost:6543/my-list-of-images") }}`

Another workaround not requiring a local web server would be to have a pre-build script called that would add the list of files into a json list in the frontmatter

```auto
+++
...
[extra]
static_images = [
"foo/bar/screen1.png",
"foo/bar/screen2.png"
]
+++

{% for img_path in page.extra.static_images %}
 ...
{% endfor %}

```

---

<div class="post-metadata">

**Author:** ![matthillco](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/matthillco/32/869_2.png) [@matthillco](https://zola.discourse.group/u/matthillco)\
**Post date:** [August 4, 2026, 12:43pm UTC](https://zola.discourse.group/t/obtaining-a-list-of-files-in-a-static-folder-without-an-index/2951/5 "2026-08-04T12:43:02Z")

</div>

Thanks for the suggestions. I’m not really a fan of adding extra dependencies or external build scripts, but I think in this case you’re right: it’s really the only way to do it. Generating a list of files using something like Python’s `os.listdir()` should work in this case.

---

<div class="post-metadata">

**Author:** ![jonhurst](https://avatars.discourse-cdn.com/v4/letter/j/b782af/32.png) [@jonhurst](https://zola.discourse.group/u/jonhurst)\
**Post date:** [August 4, 2026, 2:53pm UTC](https://zola.discourse.group/t/obtaining-a-list-of-files-in-a-static-folder-without-an-index/2951/6 "2026-08-04T14:53:25Z")

</div>

IIRC load\_data can be used with local files, including CSV, so you could just use `ls > my_listing`to create a listing file then load it as CSV. Does require a build script, of course, but not much of one.

---

<div class="post-metadata">

**Author:** ![matthillco](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/matthillco/32/869_2.png) [@matthillco](https://zola.discourse.group/u/matthillco)\
**Post date:** [August 4, 2026, 4:32pm UTC](https://zola.discourse.group/t/obtaining-a-list-of-files-in-a-static-folder-without-an-index/2951/7 "2026-08-04T16:32:41Z")

</div>

Yes, I use `load_data` all the time with local files, the previous suggestion of running a server with a CGI script to generate a file list is not necessary.

---

<div class="post-metadata">

**Author:** ![Colas.Nahaboo](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/colas.nahaboo/32/1610_2.png) [@Colas.Nahaboo](https://zola.discourse.group/u/Colas.Nahaboo)\
**Post date:** [August 4, 2026, 7:30pm UTC](https://zola.discourse.group/t/obtaining-a-list-of-files-in-a-static-folder-without-an-index/2951/8 "2026-08-04T19:30:40Z")

</div>

Yes, running a server was just for the fun of pushing the exploration to the extreme.

Just running a pre-build script is the obvious solution, with thousands of ways to implement it.

And I think most of us already use some pre and/or post build scripts anyway.

For instance, I build my site via a script that:

- perform lots of consistency & coverage checks
- create a version file to be included in footer
- git commit
- zola build
- deploy to the server
