Secrets of RSS

A number of RSS readers and, increasingly, browsers, can discover RSS feeds on your page. Typically your feed displays an icon to let the visitor to your page subscribe to your feed. But to let an RSS reader or browser discover your feed automaticallya feature called autodiscoveryyou include a <link> element in the <head> section of your page.

Here's how this works for the hamster page. Note that the HRef attribute should contain the URL of your feed, the rel attribute should contain "alternate", and the type attribute should contain "application/rss+xml" (what the title attribute contains is up to you).

<html> <head> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://rssmaniac.com/hamster.xml"> <title>My Hamster Page</title> </head> <body> <center> <h1>Welcome to my hamster page!</h1> <img src="/books/1/255/1/html/2/hamster.jpg"> <br> Yes, it's true, everyone loves hamsters. <br> How could you not? <br> I write a lot on hamsters, <br> would you like to subscribe <br> to my super hamster RSS feed? <br> (What's RSS? Click <a href="http://en.wikipedia.org/wiki/Rss"> here</a> for more info.) <br> Just use the XML button below to subscribe. <br> <a href="http://rssmaniac.com/hamster.xml"> <img src="/books/1/255/1/html/2/xml.gif" height="11" width="24" border = "0"></a> <br> Here's a great hamster page: <a href="http://www.hamsterhideout.com/"> Hamster Hideout</a> </center> </body> </html>

If you have an Atom feed, you would use the following HTML code instead:

<html> <head> <link rel="alternate" type="application/atom+xml" title="Atom" href="http://rssmaniac.com/hamster.xml"> <title>My Hamster Page</title> </head> . . .

Tip

Search engines, including Google, that search for RSS and Atom feeds use autodiscovery, so it's a great idea to add this feature to your site. For more information, take a look at www.google.com/feedfetcher.html, which explains how Google searches for RSS feeds and makes them searchable.

Категории