Email Subscriptions, RSS Feeds, and Feed Readers
2019-12-30 00:00:00 -0600

Earlier this week, a reader of this site (no, not my mother) emailed me saying that they wish that my blog had a “Subscribe” feature so they could be notified when a new blog post is published. I decided that it could be cool to implement that feature, although it may be difficult given my site doesn’t have a database or a backend.

The two most popular forms of subscription is an email service, and a live RSS feed. I started with the email service. The idea is that there’s a form for subscribers (or soon-to-be subscribers) to fill out where they enter their email address, and then a 3rd party service will add them to a list of subscribers. They’ll receive an email saying they successfully subscribed, and then they’ll receive an automated email whenever a new blog post is posted.

I followed this guide on setting up a subscribe form with a static site, and then followed that up with setting up email notifications with MailChimp. The embedded subscription form worked, the automated welcome email worked, and it was all great! Except for one big thing: the CAN-SPAM Act.

Now, don’t get me wrong, the CAN-SPAM Act is definitely useful and great, but for somebody that doesn’t own a business, isn’t selling any products, and isn’t making any money off of these emails, it seems sort of silly that I need to include a physical address where I can receive old-fashioned snail mail. I don’t have an office, and I don’t even rent a P.O. box. I could rent a P.O. box, for about $8/month. But I don’t want to be dabbling in renting a P.O. box that I won’t really get any mail to, just so I can send out occasional emails to my family and friends. So, if it weren’t for the physical address limitation, I’d probably still be using the email subscription.

So instead, I began looking into an RSS feed. This is the RSS icon icon that you see on this page, and you can probably find a similar icon elsewhere on the internet, too. RSS feeds were originally made with the goal of providing users of sites with a basic overview of the posts on a page, and updates on each page. A user utilizes an RSS feed reader to make a list of all of the feeds their interested in, and then that reader would send them updates about new posts, and link to the full post on each site. But… RSS feed readers never really gained popularity (most readers prefer to just bookmark a site and go back to it to look for updates).

But, since a reader requested it, I’ll play along and implement an RSS feed on my site, too. I followed this blog post on adding an RSS feed to a static site. It turned out to be super easy. There’s no gem requirement, and it doesn’t use any 3rd party service to compile properly. It updates the feed whenever bundle exec jekyll build is run, and auto-updates when I’m actively serving my site locally.

I added these values to my _config.yml:

feed:
  production:
    title: Emma Sax's Blog
    url: https://emmasax.com
    items: 5
  development:
    title: LOCAL Emma's Blog
    url: http://127.0.0.1:4000
    items: 5

and added this file to the root of my repository:

---
layout: none
---

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  {% assign feed = site.feed[jekyll.environment] %}
  <channel>
    <title>{{ feed.title | xml_escape }}</title>
    <description>{{ feed.description | xml_escape }}</description>
    <link>{{ feed.url }}</link>
    <atom:link href="{{ feed.url }}/feed.xml" rel="self" type="application/rss+xml" />
    {% for post in site.posts limit: feed.items %}
      <item>
        {% if post.subtitle %}
          {% assign short_title = post.title | append: " – " | append: post.subtitle %}
        {% else %}
          {% assign short_title = post.title %}
        {% endif %}
        <title>{{ short_title | xml_escape }}</title>
        <description>{{ post.description | xml_escape }}</description>
        <pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
        <link>{{ feed.url }}{{ post.url }}</link>
        <guid isPermaLink="true">{{ feed.url }}{{ post.url }}</guid>
      </item>
    {% endfor %}
  </channel>
</rss>

And it works! It works locally and in production. I can validate my feed with a feed validator, and I can add my own feed to my feed reader to test it out locally and on the pages branch.

Now we’re only left with this question: which feed reader is best? I’m still figuring out the answer to that question. I used feeder.co for most of my testing while implementing this, but it costs about $10/month, and I was just using a free trial. Granted, it did seem handy and it worked well 🤷🏻‍♀️. However, there are also browser plugins that can be used, as well as my personal favorite: subscribing to a feed straight from Slack using /feed subscribe URL.

I hope this blog post has helped you figure out your RSS feed solution. Good luck subscribing and coding!