Including numbered lists from headless page bundles


I am using a headless page bundle to store markdown snippets that are reused in our documentation.
The problem I have now is that we have several procedures (numbered lists) and some of them have common steps, so I’d like to single-source these steps into a headless snippet and only include them where needed.

For example:

contents of headless/

1. Do this
1. Then that

contents of non-headless/

{{< include-headless "" >}}
1. Step specific for this procedure
1. Another step

When rendering the site, the intended output of non-headless/procedure1 would be

1. Do this
2. Then that
3. Step specific for this procedure
4. Another step

However, the numbering restarts for the two lists, like:

1. Do this
2. Then that
1. Step specific for this procedure
2. Another step

Is there a way to avoid this, and number the steps continuously in such scenarios?
Tested with Hugo 0.62.2, goldmark.

For reference, the include-headless shortcode I use is the following:

{{ $path := .Site.GetPage "/headless/" }}
{{ $reusablePages := $path.Resources.Match $file }}
{{ range $reusablePages }}
    {{- .Content -}}
{{ end }}```

Any help is greatly appreciated.



{{% include-headless “” %}}

I’ve tried that before posting, didn’t help :frowning:

Then you have a “newline issue” or something in the file you include. You can probably verify this by

{{% include-headless “” %}}1. New item

{{% include-headless “” %}}1. New item
Renders as a separate line, with restarted numbering, even though ends without a new line. Weird.

For the record, replacing {{- .Content -}} with {{trim .Content “\n” | markdownify}} in the shortcode seems to solve the issue.