« Meaningful separation - personal blog spinoff | Main | Grazr Tip: Add a "Supersize This Panel" link for comfortable reading »

How to fix blog article link problem in ATOM feed produced by blogs using Movable Type

Audience

People using Movable Type on Yahoo! Web Hosting who want to ensure that their blog feed includes the proper permalink when viewed in Grazr

I expect this is a very small set of people.  (Actually, it may be a larger set than I thought, since as the Update below indicates, it's not specific to MT on Yahoo, or to Grazr, but to Movable Type.)

I originally wrote this for a friend who is migrating to MT-Y, but it's possible it could help a few others too, so I thought I'd share it here.

Problem 

Movable Type produces an ATOM feed in which the entry permalink URLs lead to an interface to edit the blog article.  Instead, they should point to the standard entry permalink, so readers can view the article.

Update: 2006.11.09

Apparently this is in fact a Movable Type issue.  Note that the Release Notes for Movable Type 3.3 (Beta-1) acknowledge the following "bug fix": 

21918: Atom Index does not produce valid feed

BUG FIX: Removed Atom 1.0 link relationships 'service.post' and 'service.edit' from the default Atom index template until they are more widely recognized by feed validators. In the meantime, developers can glean this introspection information from the Movable Type RSD file (rsd.xml).

Grazr provides a great way to let people graze your blog's feed, (see the "Recent Entries" on my blog's Grazr panel) but the link at the end of each article should point to its permalink, not to a way to edit the article.

SCREENSHOT Grazr link to file

Default link:

http://domain.com/blog-mt/mt-atom.cgi/weblog/blog_id=1/entry_id=1

Desired link:

http://domain.com/blog/path/to/article-permalink.html 

Even if you don't have a Grazr panel on your blog, people may use Grazr to render your blog's feed, so you probably do want the link at the end of each article to do the right thing.

This problem doesn't appear to apply to "traditional" feed readers, at least not Bloglines & Newsgator (the only ones I've checked).

I don't know if this is a Grazr problem or an MT-on-Yahoo problem, but that's not important; I've found a way to solve it that seems to work.  (See update above.)

 

Solution

Edit atom.xml template and rearrange the order of the "<link rel=" elements, so  $MTEntryPermalink is the last one.  (Or, just delete the "<link rel=service.edit" line.)

(I wrote these instructions before I knew for sure that it was safe to delete the service.edit line, so they apply to rearranging the order of the elements.)

I'm pretty sure this is happening because Grazr is using the last "link rel" as the link to the article (which may be a perfectly reasonable thing to do).  The one we want feed readers to use is the line that contains "$MTEntryPermalink".  Putting that line in the last position solves the problem:

  1. Backup atom.xml
    1. Blog control panel - Templates - click atom.xml
    2. Copy contents of "Template Body"; do not save
    3. Blog control panel - Templates - Create New Index Template
      • Template Name: "Atom Index Backup - YYYY.DD.MM"
      • Output File: [blank]
      • Link this template to a file: [blank]
      • Template Body: Paste what you copied from the original
      • Build Options: Uncheck "Rebuild this template automatically"
      • Save
  2. Rearrange the order atom.xml
    • Before:
      • <MTEntries lastn="15">
        <entry>
            <title><$MTEntryTitle remove_html="1" encode_xml="1"$></title>
            <link rel="alternate" type="text/html" href="<$MTEntryPermalink encode_xml="1"$>" />
            <link rel="service.edit" type="application/atom+xml" href="<$MTCGIPath$><$MTAtomScript$>/weblog/blog_id=<$MTBlogID$>/entry_id=<$MTEntryID$>" title="<$MTEntryTitle encode_html="1"$>" />
    • After:
      • <MTEntries lastn="15">
        <entry>
            <title><$MTEntryTitle remove_html="1" encode_xml="1"$></title>
            <link rel="service.edit" type="application/atom+xml"  href="<$MTCGIPath$><$MTAtomScript$>/weblog/blog_id=<$MTBlogID$>/entry_id=<$MTEntryID$>" title="<$MTEntryTitle encode_html="1"$>" />
            <link rel="alternate" type="text/html" href="<$MTEntryPermalink encode_xml="1"$>" />
  3. Save and Rebuild the template
  4. View your blog's feed in Grazr, and click on an article to confirm that the "Go to site / Read More" link at the bottom points to the article's permalink.  (Update: In newer versions of Grazr, the permalink is represented by the pound sign: '#'.)