Need to create a podcast-friendly RSS feed

That would definitely work - I already built a custom rss template that adds all the enclosure/podcasty things we need, but doing it with the other taxonomies (aka tagging) would give me that flexibility for the future which isn’t a bad idea.

The RSS template doesn’t support frontmatter, right? So i can’t use a redirect in there? Just thinking about migrating the existing feed URL we already have with iTunes.


Hugo uses HTML redirects which RSS wouldn’t support anyway. It’s best to handle this server side with a 301.

@mattstratton I’m super excited to see it when it’s done. Please add the site to the showcase when you launch.

I will definitely! I’m making a lot of progress (I got a little tired of the front-end work for a while and now I’m suffering through manually migrating 42 podcast episodes from Wordpress into Hugo docs)…

I could write some automation to do it, but it’s also giving me a chance to do some content housekeeping at the same time :slight_smile:

I have a working podcast site built in Hugo. I’ve offloaded the podcast-specific parts of the RSS feed to feedburner, but I did have a section RSS feed that incorporated front matter into the XML output. I never checked any of that code into GitHub, so it might be gone. But I can at least tell you what I do have working.

As I mentioned, feedburner is doing the heavy lifting. They take any post containing an MP3 and create a “media enclosure” that is compliant with iTunes and other podcast apps. I provided feedburner with a few bits of information about the podcast (description, categories, etc) and it does the rest.

Front Matter

I’ve added a few custom fields in the front matter of each post, which find their way to various shortcodes.

Date: 2015-09-24
Title: How to load test your website before a big event like Black Friday
author: Alan Bush
duration: "54:26"
length: 39188375
ogg_length: 68465422
number: "116"
summary: So you've got a big event like Black Friday coming up. Will your website be able to handle the extra volume of traffic? If you don't know (hint, you should know) then it's time to do some load testing. We'll look at a few techniques to load test your site before your big event.
- Black Friday
- Load Testing
youtube_id: ivrMJ6IETuA

mp3 and ogg are the actual audio files I generate for each post, they end up in the audio.html shortcode as described below. I store the actual audio files in a Rackspace Cloud Files container (disclosure, I’m a Rackspace employee) so that the actual audio files will still be available to podcast listeners even if the rest of the site goes offline. length and ogg_length are filesize in bytes. The shortcode does some math to convert to MB. (These are relics of the data that was passed from front matter to section RSS, and aren’t necessary anymore. I need to clean that up and just use a string to display download size.) youtube_id is passed to the youtube.html shortecode.

Short Codes

Each post is an episode recap, and includes an embed of the audio and original video, and options to download/subscribe. The audio/subscribe features are part of a shortcode:


<div class="container">
<audio controls>
        <source src="{{ $.Page.Params.mp3 }}" type="audio/mp4">
        {{ if $.Page.Params.ogg }}<source src="{{ $.Page.Params.ogg }}" type="audio/ogg">{{end}}
        Sorry, your browser does not support the <code>audio</code> element.
Download: <a href="{{ $.Page.Params.mp3 }}">MP3</a> ({{ div $.Page.Params.length 1048576}} MB) {{ if $.Page.Params.ogg }}| <a href="{{ $.Page.Params.ogg }}">OGG</a> {{if $.Page.Params.ogg_length }} ({{ div $.Page.Params.ogg_length 1048576 }} MB) {{end}}{{end}}<br>
Subscribe: <a href="">iTunes</a> | <a href="">Android</a> | <a href="">RSS</a>

That’s what I have working now. I’m going to see if I can find the work I did on creating a custom feed, so I can share that as well.

I found this RSS for the section:

<rss version="2.0"
    <title>{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}</title>
    <atom:link href="{{ .Site.BaseURL }}/index.xml" rel="self" type="application/rss+xml" />
    <link>{{ .Site.BaseURL }}</link>
    <description>Recent content {{ with .Title }}in {{.}} {{ end }}on {{ .Site.Title }}</description>
    <lastBuildDate>{{ .Date }}</lastBuildDate>
    <copyright>{{ with .Site.Copyright }}{{.}}{{ end }}</copyright>
    <itunes:new-feed-url>{{ .Site.BaseURL }}/podcasts/index.xml</itunes:new-feed-url>
    <itunes:subtitle>"This is a subtitle"</itunes:subtitle>
    <itunes:summary>"This is the podcast description"</itunes:summary>
    <itunes:category text="Technology">
        <itunes:category text="Tech News" />
    <itunes:author>"Office Hours Hangout"</itunes:author>
        <itunes:name>"Alan Bush"</itunes:name>
    <itunes:image href="" />
    {{ range first 15 .Data.Pages }}
        <link>{{ .Permalink }}</link>
        <title>{{ .Title }}</title>
        <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
        <description>{{ .Params.summary }}</description>

        <enclosure url="{{ .Params.mp3 }}" length="{{ .Params.length }}" type="audio/mpeg" />
        <guid>{{ .Params.mp3 }}</guid>

        <itunes:author>{{ }}</itunes:author>
        <itunes:summary>{{ .Content | html }}</itunes:summary>
        <itunes:image href="" />
        <itunes:duration>{{ .Params.duration }}</itunes:duration>
        <itunes:keywords>{{ .Params.tags }}</itunes:keywords>
    {{ end }}

It’s not perfect, it’s a mix of hard coded and templated content, but it worked. I still have the RSS from that section cached:, and it checks out as valid RSS:

Hope that helps, and I definitely want to check out your podcast, especially if it’s up and running on Hugo.

This is fantastically helpful. I might end up offloading our feed to Blubrry anyway, but I still want to have it generated this way for portability. The one I have working now is totally working with the episode frontmatter, although the bytes and time fields aren’t generated, so your shortcodes will help me with that!

Edit: Oh, I see now your code doesn’t calculate those values, which was the tricky part (mostly for the legacy porting; adding those values for a new episode is no big deal, but going back through the old one is a bit of a pain, but some curl/sed/awk-fu will probably help me out there

1 Like

Happy to be helpful. awk/sed was very helpful for me, as well.
Let us know how it turns out.

I think I got the feed nailed. There’s still a bit that is a tiny bit more complicated to do in the frontmatter (but it’s because of me insisting all episode numbers be xxx.mp3, instead of x.mp3, so it’s 001.mp3 and not 1.mp3, so at the moment I have the URL to the mp3 fully pathed in the frontmatter, whereas it could be dynamically generated based on episode number (which is a frontmatter param I use for something else) but it’s not the end of the world.

Here’s the code for the RSS feed:

<rss xmlns:itunes="" version="2.0">
    <title>Arrested DevOps</title>
    <link>{{ .Permalink }}</link>
    <copyright>Copyright 2015 Arrested DevOps</copyright>
    <itunes:subtitle>There's always DevOps in the Banana Stand</itunes:subtitle>
    <itunes:author>Matt Stratton, Trevor Hess, and Bridget Kromhout</itunes:author>
    <itunes:summary>Arrested DevOps is a high-level, bi-weekly panel discussion of DevOps concepts. We give our listeners a tantalizing taste of the basic technologies and ideas of DevOps to entice them to try more.</itunes:summary>
    <description>Arrested DevOps is a high-level, bi-weekly panel discussion of DevOps concepts. We give our listeners a tantalizing taste of the basic technologies and ideas of DevOps to entice them to try more.</description>
    <itunes:name>Matt Stratton</itunes:name>
    <itunes:image href="" />
    <itunes:category text="Technology">
      <itunes:category text="Software How-To" />
      <itunes:category text="Tech News" />
    {{ range first 50 .Data.Pages }}
    {{ if eq .Type "episode"}}
      <title>{{ title .Title }} - ADO{{ .Params.episode }}</title>
      <itunes:author>Matt Stratton, Trevor Hess, and Bridget Kromhout</itunes:author>
      <itunes:summary><![CDATA[{{ .Description }}]></itunes:summary>
      <enclosure url="{{ .Params.podcast }}" length="{{ .Params.podcast_bytes}}" type="audio/x-m4a" />
      <guid>{{ .Params.podcast }}</guid>
      <link>{{ .Permalink }}</link>
      <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} </pubDate>
      <itunes:duration>{{ .Params.podcast_duration}}</itunes:duration>
    {{ end }}
    {{ end }}

And an example episode frontmatter:

Description = "What does \"infrastructure as code\" actually mean? How is it different from configuration management? Special guests Joshua Timberman (Chef), Eric Sorenson (Puppet Labs), and Robyn Bergeron (Ansible) talk with Matt and Trevor about this very topic."
aliases = []
author = "Matt"
categories = []
date = "2015-10-01T08:31:42-05:00"
episode = "44"
friendly = "infrastructure-as-code"
guests = ["jtimberman", "esorenson", "rbergeron"]
images = ["", ""]
news_keywords = []
podcast = ""
podcast_bytes = "52282002"
podcast_duration = "1:02:14"
sponsors = ["victorops", "datadog"]
tags = []
title = "infrastructure as code with Joshua Timberman, Eric Sorenson, and Robyn Bergeron"
youtube = "7voRnzzUZb4"


(Sidenote - I can see that I need to fix the image referenced in the rss feed, as that is on the current (non-hugo) site, and the link will break, and also that in my example frontmatter I forgot to add the episode number alias. So good thing I posted this!)


OK, so we just went officially “live” with our Hugo-powered site. It’s online at

This is definitely MVP and we have a lot more work to do. And of course some folks may still get shunted to the WordPress version due to DNS caching (although I had the TTL dialed down to 2 minutes for a while before the cutover, so I think we are good).

The feed actually comes from Podtrack, but it ingests it from the RSS I built on the site, so it should work as expected!

Ho do you get your CDATA tags parsed properly? In my template file I have:

<itunes:summary><![CDATA[{{ .Description }}]]></itunes:summary>

However, hugo parses that into:

<itunes:summary>&lt;![CDATA[Blah Blah description]]></itunes:summary>

Since the initial < is translated into an html entity, my podcast reader chokes on it.

Have you sovled this @jmcclelland?
There’s a solution posted which says chomp gets this to work

but it doesn’t work for me using Hugo 0.40.2. I still get the < escaped to <

I haven’t read the whole thread, but reading about apparent parsing issues with CDATA, I use those in my ATOM feed template without any issue… it looks like this:

{{ printf `<title type="html"><![CDATA[%s]]></title>` .Title | safeHTML }}
{{ printf `<content type="html"><![CDATA[%s]]></content>` .Content | safeHTML }}



that has solved it. Thanks, @kaushalmodi!

For me too:

{{ `<content:encoded><![CDATA[` | safeHTML }}{{ .Content | safeHTML }} ]]></content:encoded>
      {{ `<itunes:summary><![CDATA[` | safeHTML}}{{ htmlUnescape .Content | safeHTML }}]]></itunes:summary>

Forgive me, but I must be missing something plain as day.

I’m using this in my RSS template for a podcast:

{{ `<description><![CDATA[` | safeHTML}}{{ htmlUnescape .Content | safeHTML }}]]></description>

And it is returning:

<description>&lt;p>Test description goes here&lt;/p></description>

I’ve tried chomp as well, but I’m getting the same results.

Any insight would be greatly appreciated. Thanks so much!

If this helps, since my original post, I’ve created a full theme for use in podcasts…maybe take a look at this template and see what looks different?

Archiving. Please open a new topic for any further questions or discussions and please do not revive years-old topics.