logo

How to Activate Feeding and Dynamic Bookmarking for My Pelican Blog

Di 24 September 2013 by Andreas Hüwel

Why feeding is obvious. Pelican should automatically have them running. But - for my blog and theme - it hasn’t. I guess it has something to do with new version of Pelican, while the theme itself has not yet been updated. So heres the fix. And a new feature of dynamic bookmarking the feed in Firefox.

After I’ve set up my initial pelican Blog now it is time to add some basic functionality: Proper Atom and RSS Feeding. I’ll show how to set up Atom and RSS for Pelican 3.2 and 3.3. Thereby I fix my Pelican theme tuxlite_tbs to get the feed links working and to enable firefox to dynamic-bookmark my feed (thx for the hint Jendrik ).

I think the article could also be helpful for all those who upgrade from Pelican 2 to Pelican 3. Maybe you also experience some problems with your theme and feeds and maybe this helps you locating your own problem.

As I see, my fix of the theme should stay valid also for Pelican 3.3, which was just released today.

Activate Atom and RSS Feeds in pelicanconf.py

As described in Pelican Feed Settings Documentation I power up global Atom and RSS feed:

FEED_ALL_ATOM = 'feeds/all.atom.xml'
FEED_ALL_RSS = 'feeds/all.rss.xml'
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None

With > make publish you can already see your feed files in output/feeds/all.atom.xml and output/feeds/all.rss.xml

Fix Theme to Make Your Feed Visible

My chosen theme MY_NICE_THEME is a mild adoption of tuxlite_tbs of this git repo of pelican-themes.

Alas, my theme has the link to the feed broken. It’s feed link points to the base url FEED_DOMAIN and not to the feed file.

Reading the Pelican 3.3 docs again, I see: With new version FEED_ATOM now defaults to None. And in my pelicanconfig.py I used FEED_ALL_ATOM to feed out all variants of my articles.

But my theme still uses FEED_DOMAIN/FEED_ATOM. So I now must replace that by FEED_DOMAIN/FEED_ALL_ATOM.

Where do I have to look for?

 pelican_blog_env/pelican-themes/MY_NICE_THEME/

Almost all Pelican themes, except the basic one, in that repo have that done in ‘templates/base.html’. There find and replace

            <li><a href="{{ FEED_DOMAIN }}/{{ FEED_ATOM }}" rel="alternate">Atom feed</a></li>
            {% if FEED_RSS %}
            <li><a href="{{ FEED_DOMAIN }}/{{ FEED_RSS }}" rel="alternate">RSS feed</a></li>
            {% endif %}

by this:

            {% if FEED_ALL_ATOM %}
            <li><a href="{{ FEED_DOMAIN }}/{{ FEED_ALL_ATOM }}" rel="alternate">Atom feed</a></li>
            {% endif %}
            {% if FEED_ATOM %}
            <li><a href="{{ FEED_DOMAIN }}/{{ FEED_ATOM }}" rel="alternate">Atom feed</a></li>
            {% endif %}
            {% if FEED_RSS %}
            <li><a href="{{ FEED_DOMAIN }}/{{ FEED_RSS }}" rel="alternate">RSS feed</a></li>
            {% endif %}
            {% if FEED_ALL_RSS %}
            <li><a href="{{ FEED_DOMAIN }}/{{ FEED_ALL_RSS }}" rel="alternate">RSS feed</a></li>
            {% endif %}

Allow Firefox Dynamic Bookmaring My Blog

In the same file templates/base.html you find in the <head> section some meta data. Find this lines:

<!-- Le styles -->
<link href="{{ SITEURL }}/theme/bootstrap.min.css" rel="stylesheet">
<link href="{{ SITEURL }}/theme/bootstrap.min.responsive.css" rel="stylesheet">
<link href="{{ SITEURL }}/theme/local.css" rel="stylesheet">
<link href="{{ SITEURL }}/theme/pygments.css" rel="stylesheet">

After that you add this lines:

<!-- So Firefox can bookmark->"abo this site" -->
{% if FEED_ALL_ATOM %}
    <link href="{{ FEED_ALL_ATOM }}" rel="alternate" title="{{ SITENAME }}" type="application/atom+xml">
{% endif %}
{% if FEED_ATOM %}
    <link href="{{ FEED_ATOM }}" rel="alternate" title="{{ SITENAME }}" type="application/atom+xml">
{% endif %}
{% if FEED_RSS %}
    <link href="{{ FEED_RSS }}" rel="alternate" title="{{ SITENAME }}" type="application/rss+xml">
{% endif %}
{% if FEED_ALL_RSS %}
    <link href="{{ FEED_ALL_RSS }}" rel="alternate" title="{{ SITENAME }}" type="application/rss+xml">
{% endif %}

Ready for Web

Now > make publishand then push content of folder output/ up the web.

Then everyone can either visit my site and manually copy the link you see (querbalken.net/feeds/all.atom.xml ) into your feed aggregator tool. Or they can visit my blog with Firefox and abo your feeds via bookmark -> abo this site. I have setup Atom and RSS feeds, so you are offered both options.

Thats it.

So with me pull requesting the fix to github, you maybe don’t need do to nothing for exact this theme anymore. But better be clever ;-)


Kommentare