xmlfeed

So I decided to implement a custom xml feed for this blog. One good thing about github pages is that it is really flexible with moving stuff around. In my recent changes I had added the ability for tags to exist on this blog.

This code is intentionally redacted for it to not run on this page.
---
layout: default
---
<h1>Posts tagged: page.tag </h1>
<div class="blog_by_tag">
    % if site.tags[page.tag] %
        % for post in site.tags[page.tag] %
            <a href=" post.url /"> post.title </a>
        % endfor %
    % else %
        <p>There are no posts for this tag.</p>
    % endif %
</div>

This code snippet does most of the work to handle tags. You can find a more detailed implementation at commit [727421f](https://github.com/simar7/simar7.github.io/commit/727421f22bee6dd95dc5854fef1d68f4f869dae1).

After this was the idea of implementing a xml feed. I’ve never done web development in the past so this faced an uphill task but a bit of google-fu went a long way. Ended up with an xml design (for my Mozilla projects) in a way that looks like below:

This code is intentionally redacted for it to not run on this page.
---
layout: null
tags: [mozilla]
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 <title>Simarpreet Singh - Adventures in Mozillaland</title>
 <link href=" site.url /mozilla.xml" rel="self"/>
 <link href="http://simar7.github.io/blog/tag/mozilla"/>
 <updated> site.time | date_to_xmlschema </updated>
 <id>http://simar7.github.io/blog/tag/mozilla</id>
 <author>
   <name>Simarpreet Singh</name>
 </author>

 % for post in site.posts %
    % if post.tags contains "mozilla" %
     <entry>
       <title> post.title </title>
       <link href=" site.url  post.url "/>
       <id> site.url  post.id </id>
       <content type="html"> post.content | xml_escape </content>
   </entry>
    % endif %
 % endfor %

</feed>

Update

I was given the option to contribute to Mozilla’s A-team blog and using the xmlfeed per tag I created an xmlfeed for the “mozilla” tag and was able to publish content without any extra work! You can find the A-team blog here.

Tags: Github Pages