Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

Syndication (or Web syndication) is a method which lets a Web site make its content available for others to read, listen to, or watch. When you make a blog, an Internet radio show, or an Internet television show, you are syndicating. RSS is a tool which helps to syndicate your content by organizing it into a form that's easy for machines to parse and reuse. This article provides a simple guide to using RSS to syndicate Web content.

Syndicating with RSS consists of three steps:

  1. Creating an RSS feed.
  2. Adding a special <link> element to HTML page(s).
  3. Adding a special <a> element to HTML page(s).

We've already discussed the first step—creating RSS feeds— so we'll focus on the other two steps here.

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 web page can let people and machines know about the feed by using the <link> element, like this:

<link rel="alternate" type="application/rss+xml" href="http://example.com/feed" />

Often people want to advertise an RSS feed at other places too (for example, from individual blog articles.) You can do this with code similar to 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 ("home" instead of "alternate").

There has been some abuse with usage of the <link> element for RSS syndication. Some bloggers want to make it so that others can subscribe to their blog from any page on their blog (and not just from 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 information on this). The important part when using <link> for syndicating your RSS feed is to put in the type="application/rss+xml".

Adding the <a>

While use of the HTML <link> element is powerful, it is mostly hidden. To advertise the RSS feed in a more direct way, the HTML <a> element can be used. This mimics the <link> element discussed above.

Linking from the the HTML web page where the data in an RSS feed is also contained makes the RSS feed available for use:

<a rel="alternate" type="application/rss+xml" href="http://example.com/feed">...</a>

When linking from a blog post article, use code similar to the following:

<a rel="home" type="application/rss+xml" href="http://example.com/feed">...</a>

Again, note that these two pieces of codes look almost similar. The only thing that has changed is the value of the rel attribute ("home" instead of "alternate").

Firefox does not support RSS feeds specified using rel="alternate" in its "Subscribe to this page..." feature.

Feed icons

RSS (and other) feeds use a special icon. It is recommended that you too use this icon when creating the special <a> link to your feed. The icon looks like the following:

Image:Feed-icon-32x32.png

You can get more icons like this from Feed Icons. (Other sizes and colors, along with their source files, are available too.)

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 that an HTTP client prefers to receive. This technique takes advantage 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

With real production software, though, 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 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

Document Tags and Contributors

 Last updated by: Sheppy,