Movable Type RSS Feeds

Advertisement


There's been a lot of talk about RSS Feeds lately and it seems a lot of people are still a bit unsure of what it is and how to do it.

What it is: another way for people to read your blog! A lot of people are using News Readers to read their favourite blogs these days. Providing a good feed for these people is a good way to keep them tuning in ;)

How to do it: There are a number of templates floating around. These are the ones I'm using, which I believe came from Dive into Mark originally (correct me if I'm wrong please). They're posted in the extended, with instructions. They all validate.

NOTE: These instructions are for a basic feed with Entry Excerpt ONLY. I tend to prefer FULL POSTS + COMMENTS myself. If you would like to add that option, be sure to read this post as well, for the template.


Instructions:

1. Open up your templates listing in Movable Type. If you still have the default templates, you should see two RSS templates - RSS 0.91 Index and RSS 1.0 Index.

2. Open the RSS 0.91 Template first.

3. Change the name of the Template to RSS 2.0 Index.

4. Delete the code that is in the template body and replace it with this code:

<?xml version="1.0" encoding="iso-8859-1"?> <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">

<channel>
<title><$MTBlogName remove_html="1" encode_xml="1"$></title>
<link><$MTBlogURL$></link>
<description><$MTBlogDescription remove_html="1" encode_xml="1"$></description>
<dc:language>en-us</dc:language>
<dc:creator><MTEntries lastn="1"><$MTEntryAuthorEmail$></MTEntries></dc:creator>
<dc:rights>Copyright <$MTDate format="%Y"></dc:rights>
<dc:date><MTEntries lastn="1"><$MTEntryDate format="%Y-%m-%dT%H:%M:%S"$><$MTBlogTimezone$></MTEntries></dc:date>
<admin:generatorAgent rdf:resource="http://www.movabletype.org/?v=<$MTVersion$>" />
<admin:errorReportsTo rdf:resource="mailto:<MTEntries lastn="1"><$MTEntryAuthorEmail$></MTEntries>"/>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>

<MTEntries lastn="15">
<item>
<title><$MTEntryTitle remove_html="1" encode_xml="1"$></title>
<link><$MTEntryLink encode_xml="1"$></link>
<description><$MTEntryExcerpt remove_html="1" encode_xml="1"$></description>
<guid isPermaLink="false"><$MTEntryID$>@<$MTBlogURL$></guid>
<content:encoded><![CDATA[<$MTEntryBody$><MTEntryIfExtended><p><a href="<$MTEntryLink$>" title="Continue Reading: <$MTEntryTitle$>">Continued reading <$MTEntryTitle$>...</a><p class="font-family:Verdana, Arial, sans-serif; font-size:11px; color: #333333; background-color: #f5f5f5; border: 1px solid #c0c0c0; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 4px; display: block;"></MTEntryIfExtended><MTEntryIfAllowPings><a href="<$MTCGIPath$><$MTTrackbackScript$>?__mode=view&entry_id=<$MTEntryID$>" onclick="OpenTrackback(this.href); return false">TrackBack (<$MTEntryTrackbackCount$>)</a> | </MTEntryIfAllowPings><MTEntryIfAllowComments><a href="<$MTEntryLink$>#comments" title="Comment on: <$MTEntryTitle$>">Comments (<$MTEntryCommentCount$>)</a></MTEntryIfAllowComments></p>]]></content:encoded>
<dc:subject><$MTEntryCategory remove_html="1" encode_xml="1"$></dc:subject>
<dc:date><$MTEntryDate format="%Y-%m-%dT%H:%M:%S"$><$MTBlogTimezone$></dc:date>
</item>
</MTEntries>

</channel>
</rss>

5. Save and rebuild the template.

6. Two final (but important) steps. Now that you have a feed, you have to provide a way for people to get it. There are basically two ways: One is by the auto-discovery that many News Readers use. If you open up your main index template, in the head section, you will see the following code:

<link rel="alternate" type="application/rss+xml" title="RSS" href="<$MTBlogURL$>index.xml" />

This tells News Readers where to find your feed. Make sure it is pointing to your RSS 2.0 feed, which is index.xml. I believe the default MT templates point to index.rdf so just change the .rdf to .xml in that line.

Also on your main index page you may have a "Syndicate this site" link. If you do, scroll down in your Main Index template and make sure that link is pointing to your RSS 2.0 Index. The link would look like http://www.yoursite.com/index.xml for example. Again, make sure it is pointing to your .xml file and not the .rdf one.

If you don't have a link at all, you can add one by pasting this code into your template somewhere:

<a href="<$MTBlogURL$>index.xml">Syndicate this site (XML)</a>

You're done! If anyone is interested in adding a comments feed, read on.

Instructions for adding a comments feed:

1. Create a new Index Template - call it Comments Feed and specify an output filename of comments.rdf

2. Paste the following code in the template body section:

<?xml version="1.0" encoding="iso-8859-1" ?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:admin="http://webns.net/mvcb/" xmlns="http://purl.org/rss/1.0/"> <channel rdf:about="<$MTBlogURL$>"> <title><$MTBlogName encode_xml="1"$> - recent comments</title> <link><$MTBlogURL$></link> <description><$MTBlogDescription encode_xml="1"$></description> <dc:language>en-us</dc:language> <dc:date><$MTDate format="%Y-%m-%dT%H:%M:%S"$><$MTBlogTimezone$></dc:date> <admin:generatorAgent rdf:resource="http://www.movabletype.org/?v=<$MTVersion$>" /> <items> <rdf:Seq> <MTComments lastn="15"> <rdf:li rdf:resource="<$MTCommentEntryLink$>#<$MTCommentID pad="1"$>" /> </MTComments> </rdf:Seq> </items> </channel> <MTComments lastn="15"> <MTCommentEntry> <item rdf:about="<$MTEntryLink$ encode_xml="1">#<$MTCommentID pad="1"$>"> <title><$MTCommentAuthor encode_xml="1"$> comments on "<$MTEntryTitle encode_xml="1"$>"</title> <description><$MTCommentBody encode_xml="1"$></description> <link><$MTEntryLink encode_xml="1"$>#<$MTCommentID pad="1"$></link> <dc:contributor><$MTCommentAuthor encode_xml="1"$></dc:contributor> <dc:date><$MTCommentDate format="%Y-%m-%dT%H:%M:%S"$><$MTBlogTimezone$></dc:date> </item> </MTCommentEntry> </MTComments> </rdf:RDF>

3. Save and rebuild this template.
4. Provide a link to your new feed on your main index page, which will point to http://www.yoursite.com/comments.rdf for example.

That's it.

April 7, 2003 in

More Entries From