RSS:Getting Started:Syndicating
From MDC
This page explains Web Syndication with RSS. You will learn how to make it so both people and machines can find your RSS feed.
[edit] What is Syndication
Syndication (or Web Syndication) is the act of making content available for others to read, listen to, or watch. When you make a blog, an Internet radio show, or a Internet television show, you are syndicating.
RSS helps you syndicate. RSS organizes your syndication into a form that is easy for machines to understand.
Syndicating with RSS means 3 things.
- Creating an RSS feed.
- Adding a special
<link>element to HTML page(s). - Adding a special
<a>element to HTML page(s).
We've already discussed #1 -- creating RSS feeds -- so we'll focus on #2 and #3 here.
[edit] Adding the <link>
Often the data in an RSS feed is also made available on an HTML web page. When this is the case, the HTML webpage can let people and machines know about the feed with code like the following.
<link rel="alternate" type="application/rss+xml" href="http://example.com/feed" />
Often people want to advertise the RSS feed in the other places too. (For example, from blog article.) You can do this with code like the following.
<link rel="home" type="application/rss+xml" href="http://example.com/feed" />
Note that this looks almost exactly like the previous code. The only thing that has changed is the value of the rel attribute. (The previous code had a rel value of alternate. And this code has a rel value of home.)
NOTE: There has been some abuse with usage of the <link> element for RSS syndication. Some bloggers want to make it so other can subscribe to their blog from any page on their blog (and not just their home page). This has caused many to add a <link> with rel="alternate" everywhere. (On the entries of the blog too, and not just the home page.) This is wrong! Using rel="alternate" in this case is wrong. It should be rel="home". (See Understanding rel and rev for more info on this.) The important part when using <link> for syndicating your RSS feed is to put in the type="application/rss+xml".
[edit] Adding the <a>
While use of the HTML <link> element is powerfull; it is mostly hidden. To advertise the RSS feed in a more direct way, the HTML <a> element can be used. Doing this mimics the <link> elements discussed above.
When linking from the the HTML webpage where the data in an RSS feed is also made available use:
<a rel="alternate" type="application/rss+xml" href="http://example.com/feed">...</a>
When linking from something like a blog post article, use code like the following.
<a rel="home" type="application/rss+xml" href="http://example.com/feed">...</a>
Again, note that these two pieces of code look almost exactly the same. The only thing that has changed is the value of the rel attribute. (The first piece of code has a rel value of alternate and the second piece of code has a rel value of home.)
[edit] Feed Icons
RSS (and other) feeds use a special icon. It is recommended that you use this icon too when creating the special <a> link to your feed. The icon looks like the following:
You can get more icons like this from Feed Icons. (Other sizes and colors are available too. Also, source files are available.)
[edit] Advanced Syndication Techniques
Although this advanced technique for syndication is not required, support of this is recommended; especially for web sites and applications with high performance needs.
The HTTP protocol -- one of the core technologies behind the web -- provides a way of prioritizing the content type of what an HTTP client prefers to receive. This technique takes advantage of that by having the client prefer RSS (over HTML or other formats). Here's a simple example of it being done.
Accept: application/rss+xml, text/html
Really though, with production software, it would look more like this.
Accept: application/rss+xml, application/xhtml+xml, text/html
Here's a more complete example:
GET / HTTP/1.1
Host: example.com
Accept: application/rss+xml, application/xhtml+xml, text/html
When an HTTP server (or server side script) gets this, it should redirect to the HTTP client to the feed. It should do this with an HTTP 302 Found. Something like:
HTTP/1.1 302 Found
Location: http://example.com/feed