Feed Identity

When I started to implement a JSON feed for this site, I started by building the feed according to the specification. Like the Atom standard, it requires each entry in the feed have a unique identifier.

Movable Type-Generated Atom ID

Movable Type has an in-built function to generate a string suitable for using as this unique identifier, the entry’s Atom ID, which looks like this:

tag:nostodnayr.net,2019:/links//2.80

The identifier is built in two halves, split by a colon.

  1. The first half is made from the blog’s URL and the year of publication
  2. The second half uses more specific information: the blog’s path (if not at the root), two forward slashes and two numbers separated by a full stop; the numbers correspond to the blog’s and post’s identification number in the Movable Type database

The identifiers generated by Movable Type are, above all, unique. I don’t like how database metadata is used to generate them, though. Whilst not dangerous to share, it is unsightly.

An alternative unique identifier

I hadn’t given much thought to all this until, when reading the aforementioned JSON Feed specification, I read this:

Ideally, the id is the full URL of the resource described by the item, since URLs make great unique identifiers.

It’s a brilliant suggestion. Using the permalink is simpler and elegant. We all know that cool URIs don’t change so it will always be unique. (I readily admit that I have broken URLs before; sorry, Internet. I’ve atoned where possible with 301 redirects.)

Transitioning to new Atom IDs

To make the change from using Movable Type Atom IDs to permalinks requires changing only one line in the feed template. Rather than using

<id><mt:EntryAtomID></id>

it would use

<id><mt:EntryPermalink encode_xml='1'></id>

instead. It works, but has some knock-on effects for subscribers to the feed.

Movable Type rebuilds the feed whenever there’s a new post or when an entry in the feed is edited. Changing the identifier scheme in one fell swoop would cause all previously published entries to have a new ID. This, in turn, would cause feed readers to treat all the items as new.

That wouldn’t do at all. In order to avoid causing disruption, I planned a gradual transition to the new scheme. I started by identifying the entry ID of the most recent post, which was 58. Starting from entry 59, the identifier would be the permalink, whilst older entries would use the generated ID. To accomplish this, I adjusted my Atom feed template by adding some ‘if’ logic:

<mt:If tag='EntryID' gt='58'>
    <id><mt:EntryPermalink encode_xml='1' replace='.html',''></id>
<mt:Else>
    <id><mt:EntryAtomID></id>
</mt:If>

Side note: The replace tag handles part of making clean URLs for the site. On the server, each entry is a .html file with a .text sidecar file.

Because the feed holds 23 entries at a time, I could stop including the old method after publishing entry 81. To remind myself, I added a note in an <mt:Ignore> tag.

As this entry is published, the transition to the new scheme is complete. It was conducted, I hope, without anyone noticing. Its effects will be equally unnoticed, no doubt, unless you’re someone who likes peeking into feeds.