Web Development: Specifying Feeds

Published on Sep 10, 2009   //  Development
Off

Web Development

A feed is a format to allow the retrieval of recent content. Feeds are commonly used with blogs, news outlets, etc. If you have ever used a service like Google Reader, than you will know what a feed is. Some people may be more familiar with “RSS Feed”, which is simply one of the types of formats for a feed.

All modern browsers now have an interface for displaying available feeds on the current page to the user. However, you need to add specific markup to your page for browsers to display your available feeds to the user. This is what we will be covering today.

To allow browsers to pick up on our feeds, we’ll need to use the link tag with some special attributes. We’ll need to specify that the feed is alternative content, what type of feed it is (RSS, Atom, etc), the title of the feed and, finally, the URL of the feed. For example, if you have an RSS feed you want to be discovered by browsers, you would add something like this to the head of your document.

[html]<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="http://example.com/rss/" />[/html]

While for an Atom feed, you would need to change the type attribute accordingly:

[html]<link rel="alternate" type="application/atom+xml" title="Atom Feed" href="http://example.com/atom/" />[/html]

You may specify as many feeds as you need to. For UX purposes, you should use a clear and concise title for each feed you specify.