HUGO

Generate content pages from directory content

I believe I know the answer to this, but I want to check that I’m not missing something.

Given a directory that will find a matching list and single templates, is it possible to use something like readDir to get all the files of type .xyz in the directory and use the matching single template to create the individual final pages?

Example:

myGallery/
pict1.jpg
pict2.jpg
pict3.jpg
_index.md

would output:

myGallery/
pict1/index.html
pict2/index.html
pict3/index.html
index.html

Like each image in the directory was a .md file

Note that there are no pict*.md files, but the goal would be to generate pict1.html files for each image in the directory WITHOUT having to create the pict1.md file.

If not, it’s easy enough to write a shell script to generate the pict*.md files, just was checking if I could keep it all in Hugo before complicating the build process.

Thanks

You need to write a script. Content pages are created from .md or HTML that have front matter.

This topic was automatically closed after 24 hours. New replies are no longer allowed.