Can I generate multiple static pages from a single .md?

I’m getting close to needing a backend but would be cool if i could do it in Hugo.

Basically, I’d like to have a single .md and a single partial to genearte 100 pages that are identically looking except some middle text.

Say I have an .md like the following:

layout: landing
title: Foo
  - section_id: stuff
    type: section_stuff
    start: 1
    stop: 100
  - section_id: patron
    type: section_patron
    title: Support Us
    subtitle: >-
      Bla bla
      - label: DONATE
        url: /donate
  - section_id: testimonial
    type: section_testimonial
    title: Leave a testimonial
    subtitle: >-
      Bla bla
      - label: Leave a testimonial
        url: /testimonial

I then have section_stuff.html which is a partial, given the first map (first value of the sections array) as a dict, so the partial would get the variables $start and $stop.

Inside this partial, I want to read from files myfile1.txt through myfile100.txt, do the same processing on the file content, and then output 100 different static pages corresponding to myfile1…myfile100, but dressed with the website html from hugo’s .md above.

Is there a way to achieve this without using external scripts that generate 100 different .md files? That’s what I do now via Python, and it feels silly (and a hassle to maintain external scripts)

I would also be interested in maybe doing it from the command line via Hugo, e.g. replace

    start: 1
    stop: 100


    index: $i

or something, then use hugo from the command line to give values to $i from 1 to 100, basically to use that content and layout to produce the 100 pages directly, without producing 100 .md files.

is anything like that possible?

Discovered how to hack Archetypes to achieve this. Leaving this here for the benefit of others. Create /archetypes/ with the content from the 1st post, except for the following:

{{- $i:= replaceRE "(?i)^.*?[/\\\\]n(\\d+).*" "$1" .Path -}}
    index: {{ $i }}

then from command line you can do:

hugo new stuff/

and it will generate that .md file replacing $i with 56. In section_stuff.html then you can access .section.index as a variable.

I still generate 100 .md files and the corresponding 100 html static pages (instead of only the latter 100) but at least I don’t have external scripts to maintain. Can put it all in a bash file and call the above command in a small for loop … or a proper Makefile.