Create multiple pages based on single content page

I’m trying to build out a theme that generates multiple pages from a single content file. I have a content file (example below) that contains metadata for a webinar.

+++
banner_image = "/uploads/webinarXYZ.png"
publishdate = 2020-10-30T04:00:00Z
enable_registration = true
registration_form_id = "XYZ123456789"
title = "Learning how to build a Hugo Theme"
webinar_date = 2020-11-11T04:00:00Z
webinar_url = "https://www.youtube.com/watch?v=XXXXXXXXXXXX"
[about_this_webinar]
description = "The webinar's description goes here."
host = "John Smith"

+++

I want to generate 2 different static files from this single content file:

  1. A single page that contains the banner_image and a sign up form (uses registration_form_id with a 3rd party service – not important for this question): http://example.com/webinarXYZ/
  2. Another single page with the output url prefaced with “video-” that contains the embedded webinar_url link: http://example.com/video-webinarXYZ/

I can generate the first page using the single.html template just fine. In Hugo, is there a way to generate a 2nd page using a different page template based on the same content file?

Have a look at output formats.

Awesome!

For anyone else attempting this, I added outputs to the front matter for each of my content pages like this:

outputs = ["html", "webinar"]

Then I created a webinar template named single.webinar.html which contained the HTML template for the webinar viewing page.

Finally, I added an outputFormats section to my config.toml like so:

[outputFormats]
  [outputFormats.webinar]
    baseName = "video"
    isPlainText = false
    isHTML = true
    permalinkable = true
    suffix = "html"
    mediaType = "text/html"

This generates the 2 HTML files that I needed: http://example.com/webinarXYZ/index.html and http://example.com/webinarXYZ/watch.html

Good enough for production. Thanks again @pointyfar!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.