Few things you should know about RSS template in Movable Type

in Movable Type, Webdev

I have been using Movable Type for quite long time. And one of my favorite features is its flexibility to manage the output file using our own template tags. Now, I will share some information about few things related to your RSS feed.

Before I go further, there are few things you should know about how Movable Type build the RSS file (of course, using its default template). Well, not all these facts will be directly related to RSS

  • If you leave the “excerpt” field blank when you post an entry, MT will automatically generate an excerpt automatically. The excerpt length can be defined from your weblog settings. Go to Settings → General. You will see “Excerpt Length:” there.
  • You can exclude some HTML tags using sanitize="" attribute. And you can easily manage whether you want to automatically convert breaks into new lines or not. Hint: Use the convert_breaks="" attribute. 0 means “no”.

Getting started

First, we should know about the RSS 2.0 default template, escpecially the “item-related” part. You can find other default templates in your /default_templates/ directory (packed with MT core files). Take a look at these lines:

<MTEntries lastn="15">
<item>
<title><$MTEntryTitle remove_html="1" encode_xml="1"$></title>
<description><$MTEntryBody encode_xml="1" convert_breaks="0"$></description>
<link><$MTEntryPermalink encode_xml="1"$></link>
<guid><$MTEntryPermalink encode_xml="1"$></guid>
<MTEntryCategories>
<category domain="http://www.sixapart.com/ns/types#category"><$MTCategoryLabel remove_html="1" encode_xml="1"$></category>
</MTEntryCategories>
<MTEntryIfTagged><MTEntryTags>
<category domain="http://www.sixapart.com/ns/types#tag"><$MTTagName remove_html="1" encode_xml="1"$></category>
</MTEntryTags></MTEntryIfTagged>
<pubDate><$MTEntryDate format_name="rfc822"$></pubDate>
</item>
</MTEntries>

Here are some points:

  • You will have last 15 entries displayed in your feed. Hint: <MTEntries lastn="15">
  • All the entry part (title, body text, category name, and permalink) will be encoded to XML format. Read more about encode_xml attribute.
  • Your entry body text will be used as the description. If you have new lines in your post, it will not automatically converted to breaks; focus on the convert_breaks="0" attribute.
  • If you supply the entry tags and categories, those will be displayed too.

Now, if you want to modify the RSS 2.0 default template, you know what you should modify.

Understand it using examples

You want to display only the excerpt. You don’t want to have <p> (new lines does not insert <br />.
Change <description><$MTEntryBody encode_xml="1" convert_breaks="0"$></description> to <description><$MTEntryExcerpt encode_xml="1" convert_breaks="0"$></description>
You want to display not only entry body, but also extended entry body. The output should be like what displayed in the live blog.
Change <description><$MTEntryBody encode_xml="1" convert_breaks="0"$></description> to <description><$MTEntryBody encode_xml="1" convert_breaks="0"$><$MTEntryMore encode_xml="1" convert_breaks="1"$></description>
You use Markdown text formatting in your post. How to display it “correctly” in the feed?
It is recommended that you use convert_breaks="1" attribute. Your Markdown syntax will be parsed correctly.
You want to remove all HTML tags. Once again: ALL, without exclusion.
Use remove_html="1" attibute. If want to display some HTML tags, you can use sanitize="" attribute, e.g. sanitize="strong, a href". Using this you will have bold text and anchor link in your feed (or template tags you defined).

That’s for now. You can read some other sites to help you understand about this article:

If you're new here, you may want to subscribe to my RSS feed go get the latest entry from your RSS reader. You can also have my contents delivered to your inbox.

This entry receives 2 comments.

  1. Jauhari

    About Movable Type, I can’t say too much, I never use this machine

    Mar 29, 2007 at 1:39 pm

  2. lapsed.cannibal

    Thanks for the tip — my markdown feeds are working at last.

    Aug 23, 2007 at 9:23 pm

Orangescale Podcast

If you like podcast, I also have my own podcast station (in English, Bahasa Indonesia, even Javanese language!)
Visit podcast page

Orangescale Video Blogging

Using my digital camera and also mobile device, I document interesting stuff on the street.
Check out my videoblogging

Subscribe

Buy me coffee

Do you like articles and other in my blog? If you find them useful, you can support me by sending donation.