Preface

This is one of the articles in a series about how I fine tuned my Pelican+Elegant web site to make it “more mine”. For other articles in the series, click on the title of the article under the heading “Fine Tuning Pelican” on the right side of the webpage.

Unlike my series on Choosing and Setting Up Pelican, these articles are intended to be byte sized, addressing specific fine tunings I made to my own website. As such, the first article in this series contains a Disclaimer section with generic information for each of the articles in the series.

Introduction

While it may seem counter-intuitive, the mostly text RSS Feeds have experienced a comeback in the last 5-10 years. Due in large part to a wave of automation, these feeds are mostly set up for computers to read and process new and existing articles, rather than human readers. As such, I felt it was important to provide RSS feeds for my website. This article describes how to set up RSS feeds for a Pelican website.

Strictly Speaking…

For any purists reading this, note that the output that Pelican provides is actually in the Atom format not pure RSS. This is not a major issue as most RSS readers will accept RSS format or Atom format for their readers. A good article on the differences between the two is presented here.

Only Generate Feeds When Publishing

During the normal course of writing content, I will often do a simple publish against the pelicanconf.py configuration to see how that content looks when rendered. In my pelicanconf.py configuration, the following lines are present:

# Feed generation is usually not desired when developing
FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None

Unless you are actively debugging something to do with RSS feeds, there is no need to generate these feeds during development. From a look and feel point of view, each RSS feed contains the same text as the normally viewed article, with all of the theme styling and extras removed. As such, there is usually no benefit to generating the RSS feed until the final publish step. That is why the publishconf.py configuration includes configuration to override the pelicanconf.py which enables RSS feed generation.

Generating the Right Types of RSS Feeds

To provide the right types of RSS feeds for my website, I provided the following configuration in the publishconf.py files:

# Feed Items
FEED_MAX_ITEMS = 15
FEED_ALL_ATOM = 'feeds/all.atom.xml'
CATEGORY_FEED_ATOM = 'feeds/{slug}.atom.xml'

The first line of configuration specifies that none of the feeds should not contain more than 15 items. Without this setting, a website with 200 articles would have all 200 of those articles included in the feed each time the feed was generated. In addition, when each feed was downloaded, it would download all 200 articles. For me, this setting presents a good balance between presenting a decent amount of content and sending too much data. It is very unlikely that I will publish more than 15 articles at a time, so it just seems right.

The next two lines of configuration enable the “all” feed and the “category” feeds. The FEED_ALL_ATOM configuration enables the all.atom.xml feed to be established at the location feeds/all.atom.xml. This feed contains every article is published, in reverse order of publication. The CATEGORY_FEED_ATOM configuration enables the individual category feeds, one for each category that exists. Each on of those feeds is located at feeds/{slug}.atom.xml where {slug} is the category for which the feed is being generated.

Based on the above configuration publishconf.py, when this article was written, the feeds produced were:

/feeds/all.atom.xml
/feeds/github.atom.xml
/feeds/markdown.atom.xml
/feeds/quality.atom.xml
/feeds/technology.atom.xml

What Was Accomplished

I started with a quick description of why an older protocol such as RSS and Atom are still good things to have in today’s website world. I then covered why to not generate RSS feeds until publish time, followed by how to setup and configure the RSS feeds when it was publish time. This effort allowed me to add RSS feeds to my website in a pretty painless manner, and should allow a reader to perform that same task.

Like this post? Share on: TwitterFacebookEmail

Comments

So what do you think? Did I miss something? Is any part unclear? Leave your comments below.


Published

Fine Tuning Pelican+Elegant

Category

Website

Tags

Stay in Touch