Creating RSS feeds and Automating a Newsletter
How I built RSS feeds and automated my newsletter
“RSS feeds,” or, “syndication,” or “feeds” are a type of XML-based website syndication. There are primarily two syndication formats: RSS and Atom. Atom > RSS.
- The Atom Syndication Format: describes the XML elements used in an Atom
entry, and the correct handling and display of the content of the elements.
- The Atom Publishing Protocol: describes how a collection works and how clients use HTTP GET, POST, PUT, and DELETE requests to edit the Atom entries in a collection
- w3c Feed Validation Service
- w3c Atom Docs
- Movable Type docs
- Atom: Wikipedia
- RSS Feed Best Practises
I want to write more. Not just for future reference or awareness but simply to gain clarity through composition. And ideally to get into the rhythm of putting things out into the world. I believe the pressure of communication expectations from a recurring format will provide that push to write more. So how can we actually automate this?
It’s not perfect but it gets the job done.
After getting the RSS feed up let’s figure out how to automate it into an email. Currently I use mailchimp as an email service and mailchimp offers RSS automation with automatic sending and RSS merge tags.
I was a little confused at first because mailchimp makes it seem like you can only touch the HTML of your email if you upgrade out of the free version. Luckily that’s not quite the case and you can toggle block-level HTML with the
Now that we’ve got the writing section updates working, let’s get updates on resources and around the web sections! To do this we’ll have to associate a date with each item by changing the data structure. Then we can use the generated feed.xml as a base to create the other feeds.
I went through and appended
Date: Apr 23, 2020 to every resource…
Now to combine them into an email! And wait… Mailchimp has you declare a single RSS feed to use for the entire email… So maybe we can just see what would happen if we combine the RSS feeds into one using RSSUnify? Oh god it’s just a big jumbled mess. If there is a way to filter better I could not find one albeit I didn’t look very far.
So let’s do this another way. Let’s generate an RSS feed with jekyll meant solely for the newsletter.
<items> being the sections of Writing, Resources, and Around the Web.
And we can put all the content inside
Now XML doesn’t support HTML, it needs to be converted. To solve this we can push the HTML code we need to the Jekyll
_includes folder and call it with the liquid tag alongside convert to XML. Oh wait that doesn’t work… Well maybe we can utilize liquid variables… Oh wait, you can chain filters but not place Liquid tags within Liquid tags…
After a lot of trial and error of trying to get this to work I realized that the HTML wasn’t changing and I could just input it already XML escaped to begin with…
Okay but now we need to filter for only items added within the last week. Luckily I had solved this problems earlier when trying to kinda automate emails. You can view that here.
It utilizes a Jekyll filter that pulls every post from within a week of the latest website build. To get the timeframe of a week we can set:
Then to get all writings from the last week we can:
Note the XML escaped HTML—this is not ideal for genuine RSS feeds but we’re just using this as a proxy for an HTML email so it works great.
For the Resources section I had to go through some trial and error to get the nestings right and sort them by date. Due to how the data is structured it sorts them by category and then by date:
Because the Around the Web section is built by date I can simply filter it for the first entry, which will return everything added within the current month.
Now because I appended
Date: Apr 23, 2020 to every resource the initial email will contain every single resource. I thought it serves as a nice hallmark to the day I finally figured out how to automate updates.
If you’re interested to see how it looks you can subscribe for updates.