The WHATWG Blog

Please leave your sense of logic at the door, thanks!

Feed Autodiscovery

by Lachlan Hunt in Browsers, Elements

We’ve recently added link types to HTML 5. In particular we defined the mechanism for syndication feed autodiscovery. Autodiscovery has become widely deployed and implemented already since its inception in 2002, using the link element with the alternate relationship and a type attribute indicating the format of the feed.

<link rel="alternate" type="application/atom+xml"
      href="/feed.atom" title="Atom Feed">
<link rel="alternate" type="application/rss+xml"
      href="/feed.rss" title="RSS Feed">

For backwards compatibility, we must retain support for, and explicitly define, that method. However, there are two main issues with using the alternate relationship:

To address this issue, we have introduced a new feed relationship which indicates that the referenced document is a syndication feed. This now allows you to link to several different feeds containing different content which are not necessarily alternate versions of the page.

<link rel="feed" type="application/atom+xml"
      href="/feed/comments" title="All comments">
<link rel="feed" type="application/atom+xml"
      href="/feed/summaries" title="Article Summaries">

It also means that you do not need to specify the type attribute to have the link recognised as a syndication feed and browsers can still show it in the subscription list.

<link rel="feed" href="/feed" title="Articles">

Another benefit of this is that if there is ever a new syndication feed format, you don’t have to wait for browsers to be updated with the new MIME type to recognise it as a feed. For instance, if your feed reader supports the hAtom microformat, you could subscribe to an HTML document that has been linked to as a feed.

<link rel="feed" type="text/html"
      href="/feed.html" title="All comments">

In order to retain backwards compatibility, the definition for alternate says that when used in combination with a type attribute with the value of either application/rss+xml or application/atom+xml.then it implies the feed keyword as well.

The feed keyword can also be used in combination with alternate to say that it is specifically the feed for the current document.

<link rel="feed alternate" type="application/atom+xml"
      href="/feed.atom" title="Atom Feed">

However, it’s important not to confuse this with the way alternate stylesheets works. The behaviour of rel="alternate stylesheet" is a special case where the use of alternate doesn’t mean an alternate representation of the document itself. In fact, if when used together with stylesheet, that is the one case where the type value cannot imply the feed value.

<link rel="alternate stylesheet" type="application/atom+xml"
      href="/feed.atom" title="This is not a feed!">

Mozilla already has bugs filed for implementing the new feed relationship and fixing its bug with with rel="alternate stylesheet" which are planned for inclusion in Firefox 3.0.

16 Responses to “Feed Autodiscovery”

  1. If a page supported hAtom, could this be valid: <link rel=”feed” href=””> ? I.e., a page is its own feed.

  2. Ian, that would be unnecessary, since the browser can already detect the hAtom markup in the page and offer to subscribe to it. It would just need to be implemented.

  3. And again feed discovery only talks about LINK elements, not A elements. Everybody already has an orange XML button, with an A link pointing to the feed. Why not just add the rel and type attributes to that element.

  4. Aukcje: how to make a difference between you linking to a feed you are subscribed to, and the feed for the page you are on? rel=”alternate” in the context of a body-element and rel=”alternate” in head-context seem to have different purpose to me. Aukcje

  5. The WHATWG Blog has announced the addition of a new link type in HTML5 for linking to feeds (rel=”feed”). The post notes that this can make auto-discovery easier and also makes linking to hAtom feeds tidier.

  6. Ian, that would be unnecessary, since the browser can already detect the hAtom markup in the page and offer to subscribe to it. It would just need to be implemented.

    I’d suggest specyfing self-referencing <link> anyway, since browser may not support hAtom, but user may have external application that does.

  7. Fuck! Feed is rel=”index” (& media for rss, atom or html index), for what new value?

  8. WHATWG Blog has announced the addition of a new link type in HTML5 for linking to feeds (rel=”feed”). The post notes that this can make auto-discovery easier and also makes linking to hAtom feeds tidier

  9. And again feed discovery only talks about LINK elements not A elements. Everybody already has an orange XML button with an A link pointing to the feed. Why not just add the rel and type attributes to that element…

  10. Nice information.
    And how long ago was ‘nofollow’ tag implemented? As I remeber it was the first of such kind ‘tags’. But I may be wrong
    And where may I find information on all these link types?

  11. Ian, that would be unnecessary, since the browser can already detect the hAtom markup in the page and offer to subscribe to it. It would just need to be implemented. Her yere dadanmay?n

  12. The post notes that this can make auto-discovery easier and also makes linking to hAtom feeds tidier.
    Why not just add the rel and type attributes to that element.