01 March 2008

Favicons and Hosted Blogging

When looking at your subscription list you might notice that many feeds have the same icon. For example a white-on-orange "B" for Blogger, a blue pencil for LiveJournal, a flame icon for FeedBurner and propably others...

If you visit the website of the respective feeds your browser will usually present a different icon in the URL bar. Now one might ask why cannot Liferea use the same one.

The problem is that there are two ways of retrieving these icons.
  1. Relatively to the URL of the website (e.g. as "<webserver>/favicon.ico")
  2. A specific icon file linked in each HTML documented served.
Of course just placing a "favicon.ico" file in the root directory of the webpage is the easiest way to provide a favicon. But this doesn't work anymore with hosted blogging (as provided by Blogger, LiveJournal and many others) or feed caching (as used by FeedBurner and many others). The hosted blogging solutions just do not allow you to put an "favicon.ico" file anywhere (thereby breaking discovery variant #1) and the feed cachers usually work with URL redirection to serve the cached feed content (and thereby breaking discovery variant #2).

So what should I do to help the feed reader to find my favicon?

Solution for hosted blogging: You cannot rely on a "favicon.ico" file so to replace your providers icon you have to upload an favicon image (with arbitrary name) and add a link to it directly into you HTML template. The link needs to be placed under the <head> tag and could look like this:

<link rel="shortcut icon" type="image/png" href="http://myhoster.com/content?blogId=4396446&fileId=4387343">

Note: that Liferea relies on the MIME type and will refuse all images without specified MIME type.

Solution for feed caching: You can either use the "shortcut icon" link mechanism described above or you use Atom feeds you can also specify the original "favicon.ico" file there. For RSS feeds you must fallback to specifying the icon link in the website HTML.

If you think there are better solutions please let me hear about it in the comments!


Maik said...

Specifically for cached feeds, i.e. Feedburner, Liferea could use a heuristic approach: If all standards-based attempts to retrieve a feed icon just lead to the Feedburner feed icon, then 1) find the first (or any) feed item, 2) check the GUID/Atom ID if it looks like a URL (it usually does), 3) check if there's a favicon on the host of that URL.

Based on a non-representative sample of feeds I have subscribed to via Feedburner, this would lead to an appropriate icon in most cases. I'd file it under “dirty, but it works”.

Lars said...

maik: Technically I agree it would be easy to use an arbitrary URL from one of the items. But from the implementation view point I have problems accessing items content/links from some arbitrary favicon downloading code. Also I have the feeling that is a topic the FeedBurner guys should solve as it affects many news aggregators.

David said...

And is it possible for liferea users to change icon used and pick another one ? For example, we could have a feed option to enter the website url where retrieves the correct favicon ? Or even pick a local icon.

Lars said...

David: no that's not possible. The only way would be to replace the icon in the cache directory ~/.liferea_1.4/cache/favicons, but even this would get overwritten after several days when the favicon is updated again.

Concerning your enhancement suggestion: I think that we shouldn't implement features of this complexity.

Bruce said...

I just ran into this problem with newer Digg feeds which apparently now use Feedburner. For example, the security news page is at http://digg.com/news/security and the feed is http://feeds.digg.com/digg/news/topic/

The icon for feeds.digg.com is the stock Feedburner icon, whereas it is the icon for digg.com that is desired. The channel in the feed itself, however, links to http://digg.com/. This is the channel link, not an article link, so it isn't fetching an "arbitrary URL".

Could Liferea be modified to check the channel link in feeds for a favicon? According to a 2005 post in the FeedBurner forums, this is how readers are expected to behave.

Lars said...

Bruce: This is a known issue with the HTML parser that tries to detect the favicon link. This is partially broken in 1.4 and therefore fails to detect favicons only defined in the HTML header.

I plan to fix this with 1.5.x