Friday, March 18, 2011

Blogger: Related Post Links Widget

As many bloggers will tell you, it is important make a blog as user friendly as possible. Over time the number of postings grows and it gradually becomes more difficult for visitors to navigate and find relevant information. Blogger attempts to address this need through Labels and the Archive widget. I like many others find those basic tools a bit underwhelming and have sought other means.

I looked across the net to view example implementations for Related Posts. There are a wide variety of approaches from simple link lists to thumbnails with summary text. Some of these use extensive JavaScript and require messing around inside the Blog Widget template. Others it wasn't entirely clear how they were determining what posts are related. Dissatisfied with most of what I saw I decided to write my own.

Related Post Links Widget
The Related Post Links Widget is a straight forward, easy to install javascript designed to automatically link other relevant content at the end of individual post pages. This is accomplished by reading the list of Labels applied to the current post, then fetching the site feed to find posts with All of the same labels. This post for instance looks for others with both Blogger and Widget, but excludes posts with only one.

What you get
A simple linked list of posts with All of the labels the current post has. This may be increased or decreased through a simple script change to the max_related value. Browse this blog and you will notice the links at the bottom of most posts, those with none currently have no related posts. Simple, clean and easy.

Requirements
This script does not require messing around in your template, it installs as an HTML/Javascript widget then takes care of the rest.  However, to function properly the blog must have Comments and post Labels enabled. Those two features determine if this script executes and without them nothing is shown. Visitors must also have JavaScript enabled, which in this day and age it is very rarely not.

Installation
I purposely made installation about as easy as is possible. Simply click the button below, enter a blank title and choose the blog you wish to apply the widget to. That's it, as long as Comments and post Labels are on the script should take care of the rest. If you encounter problems, please contact me either in the comments of this post or on twitter @JSBlogStop Give it a try and let me know what you think!


2 Comments
Comments

2 comments :

Srout said...

"This post for instance looks for others with both Blogger and Widget, but excludes posts with only one."

That is snazzy.

I wonder if there are other approaches you could use for the case of no other posts with the same label combination. Maybe try to approximate it with posts that have a subset of labels in common, and when a post uses all new labels just grab some random posts. :P

I currently use LinkWithin, but it's kind of been annoying me lately. It'll show posts that are clearly NOT related, and not show ones that are. [Like, I'll get a link to a post about code, on a post about fashion].

This weekend a friend and I took on a project of making our own random post widget, with thumbnails and summaries. I'd love to see what you think!

http://philenotfound.blogspot.com/2011/03/easily-styled-random-post-widget.html

Unknown said...

Nano, I thought about adding in a function to check for no results then truncating the search to fewer labels. At the time I decided against it mostly because I'm trying to manage posts with few specific label sets.

Another problem is the way Blogger manages labels, no matter the order they are input on a post they seem to be displayed alpha ordered. So, I was a bit concerned the code would end up excluding the most important label. Coincidentally I considered embedding my own label precedence through a hidden span tag within each post. It would work well for myself, but kind of messy for the general public.

I also wanted to avoid doing excessive ajax calls. Of course it wouldn't be hard to set a switch to allow just 1 more try.

Funny you mention a random post widget, I wrote a quick and dirty version for some random person on the blogger support forums recently. Started trying to finish it up for general use yesterday and hit some snags with the feeds. Should be interesting to see how you've tackled the problem.

J

Post a Comment