11ty and podcasting
It didn't take a huge amount of work to add a podcast template to that base. The result is my extremely-just-a-hobbyist, simple take on a podcast platform -- hc-podcast.
The 'base-blog' has an RSS helper already installed, so most of the work of adding a podcast feed to it comes from this
pod.njk template, and data from two sources:
A bunch of one-time data at the top of the feed that comes from
_data/metadata.json. Like the RSS helper code, that JSON file was already in the starter; I just added a bunch of podcast-specific key-value pairs. You'd obviously customize these for your own podcast.
Per-episode data from markdown files. I've cleverly saved them in a subfolder called
episodes. At the bottom of
pod.njk, there's a loop that goes through
collections.podcasts. In practice what this means is that 11ty will look for markdown files with a
podcaststag, and create an XML entry for each.
I have no idea what industry-standards exist around podcast XML files. Googling the subject results in a cesspool of spam. I created my template after skimming a couple of feeds from well-known podcast studios.
My image(s) and audio files are hosted on a $5/mo Linode server (that also does a bunch of other dumb things) and would not likely stand up to high traffic. I'm sure there are a thousand solutions out there, for this issue, but I'm just building a goof for myself with free or nearly-so tools. (If you do a global repo search for
porknachos.com, you'll see the files I'm hosting externally. As of this writing, it's just a 1600px square image for the overall feed and an audio file for each markdown episode.)
Because I'm not actually a podcaster, I needed some sample audio. I wanted something that I could generate routinely, so I dipped into an older goofy project and found a way to make it even weirder, thanks mostly to
ffmpegand Mac OS's
saycommand. The way I'm creating the episodes might be the subject of a different post; in any event, anyone giving this repo a try would clearly come to it with their own audio files.
Which reminds me that the biggest headache here is that you have to create the markdown files more-or-less by hand. Type in all the frontmatter (title, keywords, etc), and get the audio's byte-length and duration from the Finder (or whatever). I've automated this for myself, in connection with the autogenerated content, but I haven't incorporated a more-generic form into this repo, for auto-generating the markdown files and their frontmatter.
And which reminds me, if you delete all my markdown files and restart before you add any of your own, 11ty will crash because
collections.podcastsis empty. I stubbed my own toe on that, once or twice.