11ty and podcasting

11ty is a static site generator. At the top of this list, they include “eleventy-base-blog”, a template that you can fork to start a… basic blog.

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:

  1. 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.
  2. 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 podcasts tag, and create an XML entry for each.

Random notes:

  • 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 ffmpeg and Mac OS’s say command. 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.podcasts is empty. I stubbed my own toe on that, once or twice.

A brief NPM uninstall headache

It started with create-react-app telling me A template was not provided. This is likely because you're using an outdated version... Quick search and I learned that locally-installed CRA is now a bad idea; suggestion was to uninstall and, in lieu of upgrading, always rely on the npx create-react-app my-app command.

Okay but I tried a simple npm uninstall -g create-react-app and CRA was still local, somehow.

More searching… oho, it was a question of which create-react-app. Mine was in /usr/local/bin, not an npm folder somewhere. This comment got me to realize that I had a bunch of globally-installed packages under the “system” version of Node, back before I installed NVM and started relying on it.

So, nvm use system && npm ls -g --depth=0 told me what those packages were. Now that I was nvm useing the system version of Node instead of the latest, I could do a global uninstall of CRA and it actually disappeared from usr/local/bin.

For good measure, I deleted all the NPM stuff there; it was all years out of date anyway. A different SO answer gave me an awk command to tack on to the prior list command and delete everything at once: npm ls -gp --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs npm -g rm

Fun.