How to automatically create pages for files in data folder?

What I want to achieve:
My company is hiring at the moment. We have several different job offers.
In the root of our Hugo site, I created sub-folders data/jobs/{en-us,de-de}/, then added two job offers to the English (en-us) and German (de-de) version:

$ cat data/jobs/en-us/001-java-developer.md
jobID: java-developer
title: Java Developer
img: java-developer.png
description: "Random description here."
$ cat themes/mytheme/layouts/jobs/jobs.html
[...]
		{{ partial "jobs.html" . }}
[...]
$ cat themes/mytheme/partials/jobs.html
{{ $baseUrl := .Site.BaseURL }}
[...]
<div class="row">
	{{ range ( index .Site.Data.jobs .Site.Params.locale ) }}
	<a href="{{ .jobID }}/" class="jobs-link" >{{ .title | markdownify }}/a>
	{{ end }}
	<!-- For sure here is a bit more... -->
</div>
[...]
$ cat content/en-en/jobs.html
+++
categories = []
tags = []
title = "Jobs"

type = "jobs"
layout = "jobs"
+++

The /en/jobs/ site works fine in my browser.
However, I now want to automatically generate sub-folders for every job available, e.g.
/en/jobs/jobID (where jobID is the jobID set in e.g. data/jobs/en-us/001-java-developer.md)
This would make it really easy to add a new job offer.
Just by creating data/jobs/en-us/002-test.md the /en/jobs/ page would be updated, and a /en/jobs/test/ page would be created (if jobID in the 002-test.md file is set to test)

How can I do this? Or is there a better solution? I’m totally new to Hugo.

This is currently not possible by Hugo alone.

1 Like

Hi @bep, thank you for your response.

So, is there a way I can achieve what I want to do?

Would it help to create the job offers in the content directory instead of the data directory?
How can I then iterate over all pages (for /en/jobs/) and display a single job offer (for
/en/jobs/java-dev/)?

This is really similar to blog posts where you have an overview of all posts, and a single page of every blog post individually.

You need one content file per URL, so to speak.

It would be so awesome if you could tell me how. :slightly_smiling:

Either

  1. The hard way by creating them manually from a text editor etc.
  2. Write a script or a program that does it for you.

I answered “no” to the automatically question earlier, so I thought it was obvious.