Adrian Short

Design, citizenship and the city

Adding Twitter autodiscovery to your website

with 2 comments

There are various lists of UK councils which use Twitter floating around. I assume that some are compiled manually and others by screen scrapers.

Given that the rel=”alternate” attribute of (X)HTML’s <link> element is already semantically broken by the widely-adopted RSS autodiscovery spec, is there any good reason why we can’t adopt something like the code below and allow the relationship between a site and a Twitter account (or indeed, any third party site controlled by the owner) to be expressed cleanly?

<link rel="alternate" type="text/html" href="http://twitter.com/adrianshort" title="Twitter: adrianshort" />

(For HTML newbies, this goes in the <head> section of your web page.)

View source on this page and you’ll see it “in the wild” already.

Like this? Follow me on Twitter: @adrianshort

Written by Adrian Short

March 27th, 2009 at 1:57 pm

Posted in Web design

Tagged with , , ,

2 Responses to 'Adding Twitter autodiscovery to your website'

Subscribe to comments with RSS or TrackBack to 'Adding Twitter autodiscovery to your website'.

  1. Using rel=”alternate” for a site’s RSS representation isn’t semantically broken. It’s the designed purpose for the relationship of a feed as the alternate version of the site’s HTML content.

    http://www.w3.org/TR/REC-html40/struct/links.html

    Rogers Cadenhead

    30 Mar 09 at 9:12 pm

  2. Thanks for the link. Have you read it? I have.

    “The rel attribute specifies the relationship of the linked document with the current document.”

    Note that it says “document”, not “site”.

    There is no concept of a “site” in HTML. There are just documents and links between documents.

    For a rel=”alternate” to be semantically valid according to HTML the alternate content must be a different representation of the content in that actual document, not the content of some “site” somewhere.

    Thus if I have a website with a home page, a news page and an events page and I put an RSS autodiscovery link to the news RSS feed in the head of the home page this is semantically wrong in HTML. The linked feed is the alternate version of a different document.

    However, this kind of thing is standard practice because it’s supported by the RSS autodiscovery spec which as far as I can tell only really considered usage for blogs, not bigger sites with multiple sets of content. The spec’s reference to “a site’s main feed” is meaningless in many contexts.

    While it’s easy to see how many documents may share the same related stylesheet through rel=”stylesheet”, it’s very hard to see how two or more different documents could have the same alternate representation without getting into the semantic fudgery of the RSS autodiscovery spec or my own Twitter autodiscovery link above.

    Adrian Short

    30 Mar 09 at 11:54 pm

Leave a Reply