This is Atom for MT in Four Easy Steps, an entry originally posted on December 22, 2003 in the blog nebulose.net. In chronological order, before this was Commons. After this comes Typo. If you're lost, I recommend the about page.

Other destinations:


Atom for MT in Four Easy Steps

  1. Download Movable Type 2.65, released this morning. It has two security fixes, so you'll want to upgrade even if you're not going to create an Atom feed.
  2. Make a new Index Template. Output file: index.atom. Code:
    <?xml version="1.0" encoding="<$MTPublishCharset$>"?>
    <feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
      <title><$MTBlogName remove_html="1" encode_xml="1"$></title>
      <link rel="alternate" type="text/html" href="<$MTBlogURL encode_xml="1"$>" />
      <modified><MTEntries lastn="1"><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></MTEntries></modified>
      <id>tag:<$MTBlogHost exclude_port="1" encode_xml="1"$>,<$MTDate format="%Y"$>:<$MTBlogRelativeURL encode_xml="1"$>/<$MTBlogID$></id>
      <generator url="http://www.movabletype.org/" version="<$MTVersion$>">Movable Type</generator>
      <copyright><$MTBlogCCLicenseURL encode_xml="1"$></copyright>
    <MTEntries lastn="15">
      <entry>
        <title><$MTEntryTitle remove_html="1" encode_xml="1"$></title>
        <link rel="alternate" type="text/html" href="<$MTEntryPermalink encode_xml="1"$>" />
        <modified><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></modified>
        <issued><$MTEntryDate format="%Y-%m-%dT%H:%M:%S"$><$MTBlogTimezone$></issued>
        <id>tag:<$MTBlogHost exclude_port="1" encode_xml="1"$>,<$MTEntryDate format="%Y">:<$MTBlogRelativeURL encode_xml="1"$>/<$MTBlogID$>.<$MTEntryID$></id>
        <created><$MTEntryDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></created>
        <summary type="text/plain"><$MTEntryExcerpt remove_html="1" encode_xml="1"$></summary>
        <author>
         <name><$MTEntryAuthor encode_xml="1"$></name>
        </author>
        <MTIfNonEmpty tag="MTEntryCategory"><dc:subject><$MTEntryCategory encode_xml="1"$></dc:subject></MTIfNonEmpty>
        <content type="text/html" mode="escaped" xml:lang="en" xml:base="<$MTBlogURL encode_xml="1"$>">
         <$MTEntryBody encode_xml="1"$>
         <$MTEntryMore encode_xml="1"$>
        </content>
      </entry>
    </MTEntries>
    </feed>
    This is the same as the Atom 0.3 template provided by Movable Type, except I removed the optional Author Email element to protect against harvesting and changed the Copyright element to reflect my Creative Commons license. You could just use the original.
  3. Add the following line to your .htaccess file to give your feed the correct MIME type:
    AddType application/atom+xml .atom
    If you don't have a .htaccess file, create one (it's just a text file with a funny name) and upload it to the root of your public web directory. Host doesn't support/allow .htaccess? Get a better host.
  4. Link to your Atom feed from the <head> of your pages:
    <link rel="alternate" type="application/atom+xml" title="Atom" href="<MTBlogURL>index.atom" />

End result: Valid Atom

Sources and further reading: Joe Gregorio, Mark Pilgrim, Atom Wiki, The Feed Validator.

Atom feeds with other tools: more than a million at Livejournal, Atom for Bloxsom, Atom support in Drupal, Atom in Textpattern, Atom feeds built in to TypePad, more by the hour.

« Commons | Home | Typo »

Comments

I think you messed up … you want part 4 to say:

$MTBlogURL$

not

MTBlogURL

Posted by Joe Grossberg at January 6, 2004 9:01 AM :: Link

Joe:

The dollar signs around MT tags are optional — you can use them for readability (to make your MT tags stand out more from your HTML), or you can just leave them out.

Posted by Aaron at January 6, 2004 10:38 AM :: Link

Ah, sweet.

For some reason, though, it doesn’t work for me. :(

I get extra closing MTIfNonEmpty tags, and all my “modified” tags are empty.

Instead of figuring out why, I’m just going to wait until my next MT upgrade. (I just manually edited the email and XML-RPC files that had the security problems.)

Posted by Joe Grossberg at January 6, 2004 11:07 AM :: Link

Joe:

Per the changelog, MTIfNonEmpty and MTEntryModifiedDate are new tags in 2.65, which is why upgrading MT is step 1. Only explanation I can think of in your case is that the upgrade didn’t install properly — do you get “2.65” from an MTVersion tag?

Posted by Aaron at January 6, 2004 11:15 AM :: Link

No, I didn’t upgrade because I did the two security hacks by deleting one file and changing permissions on the other.

Thanks for the help.

Posted by Joe Grossberg at January 6, 2004 12:27 PM :: Link

Post a comment

Comments for this entry have been closed. Try e-mailing me instead.