How to configure Octopress for Drupal Planet syndication
Since I moved my blog to Octopress, I’ve been struggling with my
blog posts not getting picked up by Planet Drupal.
When I started using Octopress, it only had a site-wide Atom feed,
and despite my little experience with Ruby or Liquid, I managed to hack
together category-specific feeds for Octopress. These were
merged into Octopress core, so if you get the latest version from the
master
branch, you should have these.
Sadly, despite my feed being valid Atom 1.0, Planet Drupal does
not parse it properly, and my blog posts were still not included in its
feed. This might not be all that surprising to someone more familiar
with the history of the aggregator.module, which is the feed
aggregation module that ships with Drupal, that Planet Drupal uses for
its syndication.
Politely said, this module is not one of the parts of Drupal core that
gets the most attention, and its feed parsing code is not exactly
state-of-the-art. In fact, it only supports a subset of the Atom spec
and a particular version of the older and inferior RSS. Now, I won’t
get into the nasty history of web syndication technology, but
suffice to say that this is one of the instances where I find myself
wishing that the Drupal community wasn’t so NIH-prone. (that goes
for you, too, project.module).
So, long story short, if you want to be on Drupal planet, you have to
implement a feed format it understands, so I made an old-school RSS
format, that should correspond almost exactly to what Drupal itself
outputs when it generates feeds.
The template
“Drupal Planet feed template” (planet_drupal.xml) download1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<span class="line">---</span><span class="line">layout: nil</span><span class="line">---</span><span class="line"><span class="cp"><?xml version="1.0" encoding="utf-8"?></span></span><span class="line"><span class="nt"><rss</span> <span class="na">version=</span><span class="s">"2.0"</span> <span class="na">xml:base=</span><span class="s">"{{ site.url }}"</span> <span class="na">xmlns:atom=</span><span class="s">"http://www.w3.org/2005/Atom"</span> <span class="na">xmlns:dc=</span><span class="s">"http://purl.org/dc/elements/1.1/"</span><span class="nt">></span></span><span class="line"><span class="nt"><channel></span></span><span class="line"> <span class="nt"><title></span>Planet Drupal | {{ site.title | xml_escape }}<span class="nt"></title></span></span><span class="line"> <span class="nt"><link></span>{{ site.url }}/planet_drupal.xml<span class="nt"></link></span></span><span class="line"> <span class="nt"><atom:link</span> <span class="na">href=</span><span class="s">"{{ site.url }}/planet_drupal.xml"</span> <span class="na">rel=</span><span class="s">"self"</span> <span class="na">type=</span><span class="s">"application/rss+xml"</span> <span class="nt">/></span></span><span class="line"> <span class="nt"><language></span>en<span class="nt"></language></span></span><span class="line"> <span class="nt"><generator></span>Octopress<span class="nt"></generator></span></span><span class="line"> <span class="nt"><description></span>Planet Drupal RSS feed for {{ site.url }}<span class="nt"></description></span></span><span class="line"></span><span class="line">{% for post in site.categories['Drupal'] limit: 10 %}</span><span class="line"> <span class="nt"><item></span></span><span class="line"> <span class="nt"><title></span>{{ post.title | xml_escape }}<span class="nt"></title></span></span><span class="line"> <span class="nt"><link></span>{{ site.url }}{{ post.url }}<span class="nt"></link></span></span><span class="line"> <span class="nt"><dc:creator></span>{{ site.author | xml_escape }}<span class="nt"></dc:creator></span></span><span class="line"> <span class="nt"><guid</span> <span class="na">isPermaLink=</span><span class="s">"true"</span><span class="nt">></span>{{ site.url }}{{ post.url }}<span class="nt"></guid></span></span><span class="line"> <span class="nt"><pubDate></span>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}<span class="nt"></pubDate></span></span><span class="line"> <span class="nt"><description></span><span class="cp"><![CDATA[{{ post.content | expand_urls: site.url | cdata_escape }}]]></span><span class="nt"></description></span></span><span class="line"> <span class="nt"></item></span></span><span class="line">{% endfor %}</span><span class="line"></span><span class="line"><span class="nt"></channel></span></span><span class="line"><span class="nt"></rss></span></span>
How to do it
- Download the feed template attached above.
-
Put it somewhere in the
source
folder of your Octopress site.I have it at
source/planet_drupal.xml
, but the name and location
should make no difference at all. Since I have it at the route of
the source tree, my feed is available at http://mikkel.hoegh.org/planet_drupal.xml - Change the
{% for post in site.categories['Drupal'] limit: 10 %}
line to match the name of the category you want to make a feed of.
In my case, the category name isDrupal
. This is probably case
sensitive, so be sure to be consistent when categorizing your posts. -
If you haven’t done so already, tag your posts with the right
category to have them included in the feed.This is how this post is tagged, for reference. This is standard
Octopress post metadata.--- layout: post title: "How to configure Octopress for Drupal Planet syndication" date: 2012-08-12 22:32 comments: true categories: [ Drupal, Octopress ] --- [post body here]
- Redirect your current feed address or report your new feed address to
the Drupal.org webmasters.