« Google Adsense Placement After First Post | Main | Technorati Tags and Movable Type »

Simple RSS Customizations

Updated June 12, 2005. Originally posted in Spring of 2004.

The default Movable Type installation automatically publishes RSS feeds for your weblog. The three formats supported are Atom, RSS 1.0 and RSS 2.0. You can find the templates associated with these syndication formats in the templates section of your MT edit screen.

RSS-template.gif

The default RSS 1.0 and RSS 2.0 syndication feed templates for MT version 3.x produces a feed with the content in your MT entry body. The default Atom feed template produces a feed with both the entry body and the extended entry. The default RSS 1.0 and RSS 2.0 feeds in MT version 2.661 generated feeds with only the entry excerpt.

You may or may not want to publish full feeds for your weblog. There is an ongoing debate about this as avid weblog readers who use newsfeed readers generally prefer to get the full feeds of the weblogs they read. The flip side for the weblog publisher is that publishing full entry feeds can use up more bandwidth from your webhost, unless you use a service like Feedburner to host your feeds. Also, once you release all of your content in a full feed, it is very easy for an aggregator to automatically pull all of your content into their pages. Even if you have copyright protection noted on your entries, that may not stop people from using your content to create their own automatically generated portal sites. It is up to you, the weblog publisher, to determine how much of your content you want to make instantly and easily available to others without requiring them to come to your website.

Here are some simple changes you can make to your feed templates to generate a full entry feed, including the extended entry, to reduce the Atom feed to only the entry body, to create an RSS feed for a specific category or by using your RSS 2.0 template to include comments with your feed.

Changing from entry body to entry body plus extended entry

For both the RSS 1.0 and RSS 2.0 index templates, find the second instance of the description tag in the templates. In both templates that code should look like this:

<description><$MTEntryBody encode_xml="1"$></description>

Change this line so that it now reads:

<description><$MTEntryBody encode_xml="1"$>
<$MTEntryMore encode_xml="1"$></description>

Save and rebuild your templates.

Changing from full entry to entry body or entry excerpt in the Atom feed

If you want to reduce your Atom feed to only showing the entry body and not the full extended entry, find the following code in your Atom Index:

<$MTEntryBody encode_xml="1"$>
<$MTEntryMore encode_xml="1"$>

Delete the <$MTEntryMore encode_xml="1"$> line.

If you want to change your Atom feed to only showing the entry excerpt, remove those two lines and add <$MTEntryExcerpt encode_xml="1"$> in their place.

Save and rebuild your template.

Providing an RSS feed for a category.

If you would like to create RSS feeds for all of your categories, see Shelley's tips in her Generate RSS Feeds by Category tutorial.

Alternatively you can publish an RSS feed for just one specific category of posts from your weblog. For example, I publish an RSS feed for my recipe site as well as for the low carb recipes on that site. Here is the method I use, using the RSS 1.0 template. First copy and paste the RSS 1.0 Index template into a new Index template. Name the new index file something different and name the output file something other than index.rdf, for example index_yourcategory.rdf.

In your new RSS index template, find the following code:

<items>
<rdf:Seq><MTEntries lastn="15">
<rdf:li rdf:resource="<$MTEntryPermalink encode_xml="1"$>" />
</MTEntries></rdf:Seq>
</items>

</channel>

<MTEntries lastn="15">
<item rdf:about="<$MTEntryPermalink encode_xml="1"$>">
<title><$MTEntryTitle encode_xml="1"$></title>
<link><$MTEntryPermalink encode_xml="1"$></link>

Add a category attribute to the two MTEntries tags, with the name of the category you have selected to create a feed. In the following example from my recipe website I am creating a feed for my Low Carb recipes:

<items>
<rdf:Seq><MTEntries lastn="15" category="Low Carb">
<rdf:li rdf:resource="<$MTEntryPermalink encode_xml="1"$>" />
</MTEntries></rdf:Seq>
</items>

</channel>

<MTEntries lastn="15" category="Low Carb">
<item rdf:about="<$MTEntryPermalink encode_xml="1"$>">
<title><$MTEntryTitle encode_xml="1"$></title>
<link><$MTEntryPermalink encode_xml="1"$></link>

Add a category attribute to the two MTEntries tags, with the name of the category you have selected to create a feed. In the following example from my recipe website I am creating a feed for my Low Carb recipes:

<items>
<rdf:Seq><MTEntries lastn="15" category="Low Carb">
<rdf:li rdf:resource="<$MTEntryPermalink encode_xml="1"$>" />
</MTEntries></rdf:Seq>
</items>

</channel>

<MTEntries lastn="15" category="Low Carb">
<item rdf:about="<$MTEntryPermalink encode_xml="1"$>">
<title><$MTEntryTitle encode_xml="1"$></title>
<link><$MTEntryPermalink encode_xml="1"$></link>

You may want to change the title of the feed as it would appear in a newsreader. To do so, find this part of the code in your new RSS index template:

<channel rdf:about="<$MTBlogURL$>">
<title><$MTBlogName encode_xml="1"$></title>
<link><$MTBlogURL$></link>

Add the name of your category to the title:

<channel rdf:about="<$MTBlogURL$>">
<title><$MTBlogName encode_xml="1"$>: THE NAME OF YOUR CATEGORY</title>
<link><$MTBlogURL$></link>

Save and rebuild your template.

Including Comments With Your Feed

In addition to updated entries in your RSS feed you can also include in that feed new comments to your most recent entries. Here is an RSS 2.0 template that I am now using for LMT that includes the main body post, a link to the extended entry (if there is one), and any new comments made to the last "n" entries. (Via Arvind at Movalog and Jennifer at etc.)

<?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></p>
<p>
<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></p>
<p>Comments on this Entry:</p>


<MTComments><p>(<MTCommentAuthorLink show_email="0" > on
<MTCommentDate format="%b %e, %Y %l:%M %p">)


<MTCommentBody convert_breaks="0"
remove_html="1"></p>
</MTComments></description>
</MTEntryIfAllowComments>]]></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>

Just replace your existing RSS 2.0 template with the above and you will generate a feed that includes the entry body text and comments. (But don't ask me how this code works, I'm just using a template I found somewhere else!)

If you have a useful MT syndication feed template that you would like to share with others, please let me know about it in the comments.

Links:

RSS Specifications - "everything you need to know about RSS" Generate RSS Feeds by Category - Girlie's tip on how to easily generate RSS feeds for all of your categories by incorporating a new RSS template with a new archiving type. Sideblog RSS - tip for making your linkblog's RSS feed to direct the title of your entry to the linked page itself, rather than your linkblog. Comments-only Feed - scroll to the bottom of the page to get the RSS template for a comments-only RSS feed. Forcing an Unsubscribe

Comments (1)

I've figured out how to set up category feeds in MT 3.2, and have written it up:

http://www.lindamoran.net/searchwifey/MT3.2categoryRSS.html

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)