How to create Fedora feed in Jekyll

Fedora Planet. A world of Fedora contributors

Across the Linux communities, there are several people that write and maintain their own blogs across all four corners of the world. From low-skills men to professionals, a lot of contents are posted everyday and informations at all levels are available on the Internet. What about to stay in touch with Fedora people that publish on the web?

The answer is Fedora Planet. It’s an aggregator service for blogs available to contributors within the Fedora Project community.

Using categories or tags on their own blogs, contributors can “link” their blog into Fedora Planet to have any posts they publish with the matching category or tag also appear on the Fedora Planet website. You can learn more about it on the Community Blog in this article.

In Jekyll, we do everything by hand

Ok, I’m a contributor of Fedora Project and I have a small blog.
So, I would like to see my posts on Fedora Planet.

Just a little problem: my blog is made with Jekyll and it’s hosted on GitHub. This combination is amazing and simple, far away from pachyderm blog platforms like WordPress and other, but it’s also minimal by default and without easy to implement plug-in system. In Jekyll, everything is made by hand.

So, let’s go and let me develop a Fedora tagged RSS feed system for Jekyll.

JFF. The Jekyll Fedora Feed

In the last version of Jekyll, adding a RSS feed to a Jekyll blog is really super simple.

You must only create a file in the root of the site called feed.xml with the following contents:

---
layout: null
---
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>{{ site.name | xml_escape }} - Articles</title>
    <description>{% if site.description %}{{ site.description | xml_escape }}{% endif %}</description>
    <link>
    {{ site.url }}</link>
    {% for post in site.posts %}
      {% unless post.link %}
      <item>
        <title>{{ post.title | xml_escape }}</title>
        {% if post.excerpt %}
          <description>{{ post.excerpt | xml_escape }}</description>
        {% else %}
          <description>{{ post.content | xml_escape }}</description>
        {% endif %}
        <pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
        <link>
        {{ site.url }}{{ post.url }}</link>
        <guid isPermaLink="true">{{ site.url }}{{ post.url }}</guid>
      </item>
      {% endunless %}
    {% endfor %}
  </channel>
</rss>

Then, in _config.yml add this code with your data:

...
name: Your blog name
description: Your amazing description.
url: http://your-url.com
...

Finally, add the link to the RSS feed to <head> in _layouts/default.html or where you put that part of code:

...
<link rel="alternate" type="application/rss+xml" title="Your Site RSS" href="/feed.xml" />
...

Ok, now your feed is operative but if you give this feed to Fedora Planet people will read all your posts, also the posts that don’t talk about Fedora things. I have tried to modify the code to implement a ‘Tags’ and ‘Cat’ selection but nothing went fine.

I decided to make a specific feed for the Fedora related articles and it’s really perfect for the Planet. This is my solution:

---
layout: null
---
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>{{ site.title | xml_escape }}</title>
    <description>{{ site.description | xml_escape }}</description>
    <link>{{ site.url }}{{ site.baseurl }}/</link>
    <atom:link href="{{ "/fedora-feed.xml" | prepend: site.baseurl | prepend: site.url }}" rel="self" type="application/rss+xml"/>
    <pubDate>{{ site.time | date_to_rfc822 }}</pubDate>
    <lastBuildDate>{{ site.time | date_to_rfc822 }}</lastBuildDate>
    <generator>Jekyll v{{ jekyll.version }}</generator>
    {% for post in site.tags.Fedora limit:10 %}
      <item>
        <title>{{ post.title | xml_escape }}</title>
        <description>{{ post.content | xml_escape }}</description>
        <pubDate>{{ post.date | date_to_rfc822 }}</pubDate>
        <link>{{ post.url | prepend: site.baseurl | prepend: site.url }}</link>
        <guid isPermaLink="true">{{ post.url | prepend: site.baseurl | prepend: site.url }}</guid>
    {% for tag in post.tags %}<category term="{{ tag }}"/>{% endfor %}
        {% for tag in page.tags %}
        <category>{{ tag | xml_escape }}</category>
        {% endfor %}
        {% for cat in page.categories %}
        <category>{{ cat | xml_escape }}</category>
        {% endfor %}
      </item>
    {% endfor %}
  </channel>
</rss>

And save that as fedora-feed.xml in your main path and remember to tag your posts with the word Fedora or change it in the code above.

At last, join the Planet following this instructions and provide a .planet file like this:

[http://your-blog-with-jekyll.com/fedora-feed.xml]
name = Your Name
face = http://yourname.fedorapeople.org/yourpicture.png

After all, it may take time for the server to sync, but you can check the Planet to see if your blog posts are also there.