Neil Turner's Blog

Blogging about technology and randomness since 2002

Do you want GUIDs with that feed?

Dan Gillmor has discovered GUIDs in RSS feeds. They’re a very useful thing, because they help to identify individual entries in a feed, so if you were to change an existing entry it wouldn’t show up in an aggregator as being new. The situation is described best in this piece by Steve Poynter.

I’ve always used GUIDs in my feeds for this reason, even in the excerpts feed, which is designed to be a minimalist feed with as many tags taken out as possible. If you’re using Movable Type, GUIDs are quite easy to implement in your RSS feeds, however, as with just about anything to do with RSS, there’s some confusion surrounding them.

A GUID, by definition, is a ‘global unique identifier’ – that means it is always unique. No two entries can have the same GUID value. In Movable Type this isn’t a problem because all entries are assigned an ‘entry ID’, a number which is generated with each entry and cannot be changed. According to the RSS 2.0 spec, a GUID is a string that uniquely identifies the item. The emphasis is mine – the GUID only has to be a text string, but it can also be a URL, and this is where the confusion comes in. I’ll show you two code examples for implementing this in Movable Type – which one you choose is up to you.

<guid isPermaLink="true"><$MTEntryPermalink$></guid>

This is similar to the example given by the RSS spec itself. The GUID here is the URL of the item, which, in a default Movable Type installation, is fine, since the filename of the entry uses the entry ID (such as ‘/archives/001234.html’) and will therefore always be unique. The problem comes when you get people like me who prefer to have more meaningful URLs – in my MT configuration I’ve changed the archive filename format for my individual entries so that the filename is the title of the entry, sorted into folders by date (such as /2003/Dec/07/foobar.html’). While it looks better, the problem is that if I change the title of an entry, then if I use the above method, the GUID will change. This means that an aggregator that supports GUIDs will think that I have a new entry, when in fact I don’t; I’ve just edited an existing one. So, to solve that problem, here’s what I use:

<guid isPermaLink="false"><$MTEntryID$>@<$MTBlogURL$></guid>

The above string is not a link, but it is a unique string. You can edit the title all you like and the GUID will always be the same. It just won’t be a permalink, that’s all.

Is there any real disadvantage to the second method? No, not really. Probably the only downside is that if you use the second method, you must then have the permalink in a <link> tag – with the first method, it is optional because you have already specified it. But even then, I wouldn’t recommend removing <link> because whereas just about every aggregator under the sun understands <link>, only the more advanced ones support <guid> – those older aggregators will think your feed has no permalinks at all.

For more on GUIDs, have a read of Dave Winer’s article on the issue.

Comments are closed.