Rendering two pages for each markdown file

This question is pretty close to what I’m trying to do, but after reading this & the Output Format doc, I’m still having trouble achieving what I want…

I’m using Hugo for a podcast site. Each episode is a separate markdown file in /content/podcast. Currently, they are rendered using /themes/…/layouts/podcast/single.html into /podcast/Episodes/{episode number}-{name of episode}/index.html.

What I want to do is also add a /player.html page into the same folder, generated using a different layout, but have that page not use any of the other nested layout pages… I want the template to be the only thing that’s rendered (it’s going to be used within an IFRAME so none of the site header/footer/sidebar/nav will be included).

I think need to (1) update my output format for the podcast to point to another template like the above-referenced question was looking to do, but I’m having trouble getting the config.yaml file just right. Then (2) I need a template /themes/…/layouts/podcast/player.html that the new config points to.

Question:

  • I’ve tried outputs and outputFormats… but everything I’ve done just keeps breaking the build. I added podcast to my existing outputFormats but not sure how to point to the template. Something it’s clicking for me… someone have a pointer to push me in the right direction?

    outputFormats:
      RSS:
        baseName: rss
      podcast:
        baseName: player
        mediaType: text/html
    

Hi,

Do you have your code somewhere we can have a look at? It does sound like you are close though.

I didn’t, but now I do. https://github.com/andrewconnell/repro-hugo-post

Here’s the commit of the work I’ve done to enable what I’m trying to do. Right now it isn’t generating the player file within the episode folder alongside the index.html file.

https://github.com/andrewconnell/repro-hugo-post/commit/da42f47325b3914152eef013cfb405bc2a4b7d8d

A few things:

  1. Rename layouts/podcast/player.html to layouts/podcast/single.podcast.html (ref: https://gohugo.io/templates/output-formats#templates-for-your-output-formats )

  2. Set the outputs in the content front matter (ref: https://gohugo.io/templates/output-formats#customizing-output-formats )

  outputs: 
    - html 
    - podcast

I’m assuming here that you only want content/podcast/foo.md to get the podcast output generated. Otherwise, you can add the outputs to the site config instead.

You may want to take advantage of the new cascade feature as well: https://gohugo.io/content-management/front-matter/#front-matter-cascade

4 Likes

Awesome… this is EXACTLY the guidance I was looking for. Thanks!