August 8, 2006

Hack to display related posts from Blogosphere

John at Freshblog has listed the statistics about blogosphere in this post. At the rate of 175,000 new blogs created each day, it is not easy to find the posts that you are interested in. Thankfully, Google blog search and Technorati search help us in this arduous job. But still, one has to use complex search operation with multiple keywords to get the most relevant results.

This hack is aimed at easily finding other posts from Blogosphere that are related to the one that you are currently reading. Here's how it works:
1. It picks up the post title and removes the trivial words such as "for", "of" etc.
2. It then performs a context-sensitive search operation using Google blogsearch with a combination of "all words" search and "exact phrase" search. This is to avoid irrelevent posts that could show up with a simple "all words" search as much as possible. (Note that this is still "best effort" only).
3. The search results (first 5) are obtained in RSS format and my PHP script condenses it to display only the relevant post's title, link, creator's name and creation date. (I did not use's service because of some special processing required such as removal of html tags etc).

To summarize, every post page subscribes to its context-sensitive search feed and the freshest relevant posts are shown at anytime.

The best way to use this feature is to add a bookmarklet to your browser as Greg suggested while introducing this feature at Freshblog. Here's how to do it:

1. Just right-click the link below and "Add to favorites" (preferably under Links folder so that it shows up in Links bar). IE might complain about bookmarking javascript code. Ignore it and continue to add the bookmarklet. If you are using firefox, right-click, choose "Bookmark this link" and add to Bookmarks toolbar.

Find related posts

2. Whenever you are in your/another blog and you would like to read more on the topic, just click this bookmarklet and it will take you to a page that shows related posts.

You could also plug-in this feature to your blog itself by changing your template. Add the following piece of code right after the Backlinks section (indicated by </BlogItemBacklinksEnabled>) or after the comments section (indicated by </BlogItemCommentsEnabled>).

<script language="Javascript"

An interesting note: You can see the hack in action at the bottom of this page. The second relevant post is about aditya's similar hack to display relevant posts in "create post" page. I would have never known about it if not for this hack!! So, you never know what you are missing if you don't try this ;-)


Anonymous said...

Man, it's a great hack, but how to display just the realted posts from your blog only?

Anonymous said...

Oups sorry, bad reading! ^^

TerraPraeta said...

This looks like a really cool hack -- but I find that it does not really work for me, because my titles tend to NOT be literal.

But I love the other hack: for Featured Archives!



David Hunter said...

Hey Ramani would you mind emailing me a copy of this script? I'd like to try and modify it so that I just get related posts from my blog do you think that could work? My email is