I’m trying to create a template or shortcode that lists the files in a directory.
My particular use-case is that I’d like to have a page that lists the contents of a directory full of .wav and .mp3 files. Each file does not require its own page, so having the list template/shortcode display a direct link to the file is what I’m trying to do.
Ideally, I’d like to figure this out on my own, as I’m mainly using Hugo as a hobby. If .ResourceType / .MediaType is indeed the correct direction to go in, please let me know. If not, all I ask is a point in the right direction, and I can eventually figure it out from there. Thank you!
So I tried your shortcode and couldn’t get it to function properly. After replacing your target directory with mine (static/audio), the page properly renders but does not list the files. Ju52, if you would be so kind, can you explain the string “/etc/%s/%s” found on line 10? I’m having a hard time understanding how to parse in my directory at that point. Would it be “/static/%s/%s” as to reflect my target directory?
My apologies for the lack of understanding, I’m in no way a programmer, ha.