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 theconvert_breaks=""attribute.0means “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_xmlattribute. - 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 usesanitize=""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:
This entry receives 2 comments.
Jauhari
About Movable Type, I can’t say too much, I never use this machine
Mar 29, 2007 at 1:39 pm
lapsed.cannibal
Thanks for the tip — my markdown feeds are working at last.
Aug 23, 2007 at 9:23 pm