RSS (Really Simple Syndication) for Dummies
by Stanislav Sýkora, Extra Byte, Via R.Sanzio 22C, Castano Primo, Italy, and Ernesto Bonardi, EdreamLab, Mortara, Italy
in Stan's Library, Ed.S.Sykora, Vol.II. First released July 4, 2007
Permalink via DOI:  10.3247/SL2Web07.001
Programming Section of Stan' LIBRARY | Code snippets | HTML Entities and Character sets Stan's HUB

Despite its name (Really Simple Syndication), and despite the fact that I decidedly wanted to implement a syndicated news service for my Stan's Library and for my NMR blog, I was for a long time too scared to act on it. What kept me scared were stories told by friends and would be experts about how I needed to install this or that software, how I had to check whether my server supported cgi, php, and I don't even remember what else (the list appeared to be so long). Until I and Ernesto have tried ourselves and discovered that not a single one of those claims was true! RSS service is indeed so 'really simple' that anybody, even a complete www-dummy, can set it up in 15 minutes and it does not need any special support from your hosting provider.



1. What is this article about

Suppose you have an internet site which publishes more or less regular newsworthy items (articles, comments, announcements, lists of events, ...) and, though you are no professional journalist, you would like to give your visitor the opportunity to subscribe to it as though it were a newspaper or a magazine. In a bit more professional terms, you would like to propose your site as a news agency, offering news leads to whomever might like to follow them on a regular basis.

A typical User of your news will be a regular visitor of your site who wants to be automatically alerted every time you publish something new or, maybe, just point out something you deem interesting. Of course, your visitors probably have many different interests, so they will want to combine (syndicate) your news with news leads from other sources by subscribing also to a number of other news agencies of their choice. For that purpose they will use a syndicated news aggregator (or just aggregator) which is either a self-standing piece of software (there are many af them available for free on the internet) or simply a part of the most recent versions of internet browsers.

This article is for you
(i) if you want your site to become a source of news leads which your readers can syndicate using the RSS concept,
(ii) if you have no idea about how to go about it,
(iii) if all the theory you ever want to hear about is what you have just read in the preceeding two paragraphs and, especially,
(iv) if you want to be up and operative in 15 minutes.

2. What I need to do to convert my site into a syndicatable source of news leads

Step A: Create an XML news channel container
Using NotePad, WordPad, or any other pure-text editor, create a new text file named, for example, doomsday_rss.xml and give it this initial contents:

<?xml version="1.0"?>
<rss version="2.0">
 <channel>
  <title>Doomsday News</title>
  <link>http://www.mysite.com</link>
  <description>News and articles selected/written by myself</description>
  <copyright>Copyright 2007, MyNameOrCompany</copyright>
  <webmaster>webmaster@mysite.com</webmaster>

 </channel>
</rss>

The actual name you will give this file is up to you but you should keep the extension xml. In principle, it is not necessary but you never know how clever are all the news aggregators out there in the jungle. It is also good (though not compulsory) to keep the rss somewhere in the name so that, later on, you will always know what the file is about without having to open it.

When copying the text, DO NOT use any formatting tags or special-character entities (if you think you really need them, read the second FAQ). XML files are NOT html files; the final text must look exactly as shown above, except that you must the italicized text with a non-italicized text of your own. For formatting, use spaces, tabulators, carriage returns, line feeds, and empty lines - all such whitespace is ignored by aggregators.

Explanation of the individual lines:

= The first two lines identify the type of the file contents and the RSS version. Do not change them. The XML element <rss ... > on the second line goes in a pair with the closing </rss> on the last line. The first two lines make the document an RSS+XML file.
= The XML element <channel> starts the description of a news channel and is terminated by the </channel> on the penultimate line. A single RSS+XML file may contain many news channels. Alternatively, you could have several distinct RSS+XML files, each containing just one news channel. Initially, you are likely to need just one news channel, so this aspect is of little importance to you. Even so, however, you must provide a description of your channel which is contained in the next five lines.
= The XML element <title>...</title> encloses the name which you wish to assign to your news channel. You should avoid names like New York Times. It is not that they might sue you (they probably could not) but confusion does not help anybody, including yourself.
= The XML element <link>...</link> should specify the URL of your site. Alternatively, it could be also the URL of the the main page of the particular news channel (something like a news agency main office).
= The text enclosed by the XML element <description>...</description> is up to you. It is optional but very useful.
= The XML element <copyright>...</copyright> is optional but if you include it, you might once come back to thank me.
= The XML element <webmaster>...</webmaster> is optional. Typically, it is a contact to whomever is responsible for the news channel (not necessarily for its contents). Including it, you indicate that you are not a drug pusher.

Step B: Insert start-up news leads
Now that you have created a news channel container, insert into it some start-up news leads.
Here is an example with two news items (the already handled sections are grayed):

<?xml version="1.0"?>
<rss version="2.0">
 <channel>
  <title>Doomsday News</title>
  <link>http://www.mysite.com</link>
  <description>News and articles selected/written by myself</description>
  <webmaster>webmaster@mysite.com</webmaster>

 
  <item>
    <title>Last minute grace: the World is safe</title>
    <link>http://www.tibetnews.com/headlines/10062007_001.html</link>
    <description>Humanity granted another term, God tells a child.</description>
    <pubDate>10 Jun 2007</pubDate>
  </item>
 
  <item>
    <title>End of the World imminent!</title>
    <link>http://www.mysite.com/heavenlynews/news.html#1</link>
    <description>Angel says the world will end at midnight tomorrow.</description>
    <pubDate>8 Jun 2007</pubDate>
  </item>
 
 </channel>
</rss>

Each news item (lead) is enclosed between the XML elements <item>...</item> and typically has just four attributes. The RSS standard actually specifies many more, but they are optional and you do not need them for starts (the same applies to the news channel attributes). Again, DO NOT use any html formatting tags within the text strings you will supply.

Explanation and comments of the individual news item (news lead) attributes:

= The XML element <title>...</title> specifies the news item's heading. It may be the name of a new article on your site, or a new product, or anything else. The wording is totally up to you.
= The XML element <link>...</link> should be a valid URL to the main story (article, product page, whatever). It will usually point to your own site, but that is not at all compulsory. If it points elsewhere, you are simply saying to your readers: "look at this, I find it interesting".
= The XML elements <description>...</description> should provide a brief description of the news item. Since it is a lead, it should not be used as, nor confused with, the item itself. Rather, you should consider it as a sub-title. Bear in mind that when the description is too long, many aggregators cut it mercilessly to a couple of lines.
= The XML element <pubDate>...<pubDate> specifies the publication date of the news lead. It need not coincide with the moment when the news actually happened, though one would assume it to be close to it. Use the specified format, with the first 3 letters of the english name for the month. If you wish, you can be more precise using the format
   <pubDate>Tue, 27 Jun 2007 15:30:00 GMT<pubDate>
but that is hardly necessary unless you plan to generate many news feeds a day (in which case you should consult a specialist).

Step C: Upload the RSS XML file to your site
Using your standard FTP access, place the XML file you have just created somewhere in your site. For your own convenience (such as remembering where you have put what), I suggest you put it in the site's root directory.

Step D: Provide one or more RSS buttons for your readers
Now that you have established a file for your news leads and are ready to start adding new ones (you will see shortly how), you must give your readers an opportunity to 'subscribe' to your newborn news agency. Before you get wrong ideas, let me tell you that such 'subscriptions' are (i) completely free of any charge, (ii) completely voluntary and (iii) totally anonymous. You will never even know how many have subscribed and who they are. All you can do is tell the public the location (URL) of your RSS+XML file.

You could do that simply by writing somewhere on a page of yours something like:
   My RSS+XML file is: www.mysite.net/doomsday_rss.xml For experts, this would do, but it is a bit unusual and it does not have a proper visual impact.

What you should do instead is prepare a little bit of graphic including the standard RSS button. It can contain a lot of other promotional stuff as well, the only important thing is that it is inserted in a link to your RSS+XML file and when a user clicks on it, it displays it as xml text. As an example, consider the RSS button I use to show my Stan's Library RSS+XML file. The file is named libraryrss.xml, the button graphic is "libraryrss.gif", and both are located in the root directory of the site www.ebyte.it (the URL of the library itself is "www.ebyte.it/library/Library.html", but that is irrelevant here). To place the button somewhere on a page, I use the script

<a target="_blank" href="http://www.ebyte.it/libraryrss.xml">
   <img src="http://www.ebyte.it/libraryrss.gif"> </a>

and the button looks like this (click on it to display Stan's Library news feeds):

So, all you need to do is to (i) prepare a graphic you like with an RSS button in it like the one on the left (it is a GIF image and yes, you may copy it), (ii) upload it to your site into the same directory where you have placed the RSS+XML file, and then (iii) copy my two-line syntax into all places where you wish to put the button (naturally, you must replace my URL's with yours). A note for html-wise experts: the RSS button is no functional button in the sense the term is used in forms - it is just a little piece of graphic.

There is a minor complication. The Linux crowd (plus Mozilla browsers) prefer a different graphic symbol in place of the RSS button. It looks like the little icon which starts this paragraph. There is a little difference, though. Tendentiously, this icon indicates a single news lead, not an RSS news channel. It is therefore used a lot by aggregators, while there is no obligation for you to use it in the context we are discussing here.

You might have a hesitation as to where exactly you should put the RSS button(s). You can place any number of them on as many pages as you like. They can't do any harm; they simply advertise that you have an RSS-compatible news channel and provide the link to the respective RSS+XML file. For example, you could place a button at the bottom of every article you write, plus on your home page, plus on your site map. There is no law to limit you.

Once you have placed the buttons, don't forget to test them to see whether your links are correct and whether the RSS+XML file displays correctly (should there be any syntax mistypes, the browser would display an error message rather than the file contents). If all is OK then your readers already see you as an RSS news provider - figuratively speaking, your news agency's front is up and lighted.

Step E: Inform new browsers about your RSS feeds
This step is optional but, since you have got this far, you should try it out. The most recent versions of web browsers start providing build-in RSS support. One cosy thing is their capability to automatically show a link button to a particular news channel when displaying a web page. Suppose that you have an html page named ApocalypseNow.html and you would like the newest browsers to show a link to your Doomsday News whenever the ApocalypseNow page is being viewed.

To achieve this, you only need to insert this line somewhere in the <head>...</head> section of the ApocalypseNow.html file:

<link rel="alternate" type="application/rss+xml" href="http://www.mysite.net/doomsday_rss.xml" title="Doomsday News">

naturally adapting the value of href and title to fit your setup.

3. How do I release fresh news leads

Suppose there is a new item (a story, an article, a product, an event, a piece of art, whatever) which has an URL and which you would like to point out to your news channel audience. All you need to do is to modify the RSS+XML file on your server, inserting the new lead into it.

You can download it from the server, modify it, and upload it again. Or, for convenience, you might like to keep a copy of the file on your computer. In that case, you just modify that one and upload it to the server. Whichever the case, the modified file will look like this (again, the 'old' sections are grayed):

<?xml version="1.0"?>
<rss version="2.0">
 <channel>
  <title>Doomsday News</title>
  <link>http://www.mysite.com</link>
  <description>News and articles selected/written by myself</description>
  <webmaster>webmaster@mysite.com</webmaster>

 
  <item>
    <title>Solemn Pledges of Evelasting Peace</title>
    <link>http://www.jerusalem.net</link>
    <description>All major religions join hands to thank God.</description>
    <pubDate>23 Jun 2007</pubDate>
  </item>
 
  <item>
    <title>Last minute grace: the World is safe</title>
    <link>http://www.tibetnews.com/headlines/10062007_001.html</link>
    <description>Humanity granted another term, God tells a child.</description>
    <pubDate>10 Jun 2007</pubDate>
  </item>
 
  <item>
    <title>End of the World imminent!</title>
    <link>http://www.mysite.com/heavenlynews/news.html#1</link>
    <description>Angel says the world will end at midnight tomorrow.</description>
    <pubDate>8 Jun 2007</pubDate>
  </item>
 
 </channel>
</rss>

Notice that the newest leads is on top - the first news lead comes just after the channel description. This is logical and a good practice, too. Most news aggregators assume this logic and do not do any chronological sorting of your news leads.

4. Frequently asked questions

If implementing RSS is so simple, why all texts about it I could find sounded so complicated?
There are three reasons:
(1) The wise guys try to tell you everything rather than just the minimum needed to start,
(2) They think you might be a news agency issuing every minute news leads on hundreds of channels,
(3) They want to sell you a software utility and try to prove that you can't live without it.
Do you mean that software utilities for RSS are useless?
No, they are not, but the best approach to anything is to first try and do it yourself. Start looking for a utility only after you perceive a need for it. This said, it is clear that you might do with a little tool which includes color-enhanced editing and syntax checking of the RSS+XML file and simplifies (or makes transparent) the download-modify-upload process implicit in releasing fresh news leads. There are many of them available on the Internet and they are mostly very affordable. Avoid the costly ones; if your name is New York Times, you should have an ad-hoc RSS software written for you. Otherwise, a $20 utility is a reasonable investment.
Why did they tell me the server had to support things like cgs, php, perl, etc?
These were the requirements of the utilities they wanted to sell. They probably included server-side software which, I think, is an overkill for something as simple as RSS. Personally, I would prefer utilities which rely just on basic FTP.
Do you sell an RSS utility yourself?
No, we don't. Should we write one in the future, we would tell you.
We are running a Business. Is there a commercial advantage for us in the RSS?
Not a direct one. People subscribe to your news only if they find them interesting, they do so free of charge, and they can unsubscribe at any moment. You can not sell the news leads as such, nor can you put ads into the RSS+XML file. Once you bring people to your site, of course, you can sell the actual items (articles, new products) and/or place ads on your pages. You can view the RSS as a commodity for your regular visitors which makes it more likely that they will come back (boost in the the faithfulness factor). For hit-and-run businesses RSS may be counterproductive.
Will RSS increase my site's traffic?
Not necessarily. When I introduced RSS, I saw a significant drop in the daily number of visitors. This is because the regulars, once they subscribe, no longer need to visit and browse your site to know whether you have something new for them. They rely on being automatically averted whenever you do. So this part of visits to your site will decrease and become dependent on how frequently you issue news leads. Occasional visitors and the traffic directed to you by search engines, of course, remain unaffected by the fact that you support RSS. So if your goal is maximum visitor numbers then RSS is not exactly what you need, but if you are after community building and visitor care then RSS is perfect.
Will RSS boost my site's ranking with search engines?
I assume that it will - but not dramatically so. It is just one more point in your site's favor. Widespread use of RSS tends to reduce the traffic on the Net, making it less random and more relevant, something search engines should like. But who knows how those robots reason?

References and links
(See also this site's List of Web programming books)

Special ackowledgment by the Authors is due to Mauro Cremonini for his prodding and helpful advice. 

TOP | Programming Section of Stan' LIBRARY | Code snippets | HTML Entities and Character sets Stan's HUB | TOP
   
Copyright ©2007 Stanislav Sýkora    DOI: 10.3247/SL2Web07.001 Designed by Stan Sýkora