Switchin to Tags in pyblosxom

Posted Mon, 24 Oct 2005

Inspired by Pete, and intrigued by the word Folksonomy, I decided to switch my blog to use tags for organization rather than categories.

The birds-eye difference is minimal, I can have multiple tags per entry, whereas each entry belongs to only a single category. While that doesn't sound very powerful in and of itself, using tags extends your ability to relate posts to each other, creating a more meaningful reading experience for your blog.

Getting started with Tags in pyBlosxom is a two step process:

  1. Install Joe Topjian's Tags plugin. I've done some work on it lately and submitted my changes to Joe - meanwhile you can find my version of it here.
  2. Install my Tag Cloud plugin.
Installation of both plugins is very simple, just copy them to your pyblosxom plugins directory (rename the plugins to have a .py extension; the .txt extensions are for web browser convenience).

Once those are in place, we're ready to start tagging our entries. This can be a pain, because pyBlosxom uses the entry file's last modified date as it's post date. I edited each file by hand on Mac OS X (this will also work on any Unix), using a text editor and the touch command, like so:

Oct 23 17:17:05 2005 about.txt
> nano -w about.txt && touch -t 0510231717.05 about.txt
This will retouch the file to its original date immediately after my text editor returns.

To add a tag, simply add a #tags section to your entries metadata, like so:

About Timothy Fanelli
#tags about
<p>My entry goes here.</p>

Alternatively, you could use the one of the various plugins available for editing pyBlosxom entries, or a plugin that caches files post times instead of using the mtime.

Once you have your entries tagged, you should add the $tags variable to your story template, and add the $tagcloud or $populartagcloud to your flavour template. Mine is in my foot template where I define my sidebar. Simply add one of the two tag cloud variables where you want your tagcloud to appear:

The popular tag is generated by taking tags from the full cloud that would be at least a "medium" weight, recalculates the distribution, and applies new weights to the abbreviated cloud. This is useful if you have a lot of tags with few entries that don't really apply to your blog's main topic. I'm working on an extension to the plugin that will allow you to show the full cloud as an entry, check back for updates soon!

Once you have this in place, you're all but done! Your blog now has full tag support, in addition to your regular category structure.

I've gone one step further on my blog and eliminated my category structure all together. I did t his by moving all my entries into a single category called "item". I then used apache's mod_rewrite to redirect requests for categories to the closest appropriate tags, and to redirect my old permalinks to the entry's new home in the item category - here's a sample of my rewrite rule section of my httpd.conf:

RewriteEngine on
RewriteRule ^/blog/linux/?$ /tags/linux [R=301]
RewriteRule ^/blog/windows/?$ /tags/windows [R=301]
RewriteRule ^/blog/xml/?$ /tags/xml [R=301]

RewriteRule ^/blog/linux/(.+$ /blog/item/ [R=301]
RewriteRule ^/blog/windows/(.+)$ /blog/item/ [R=301]
RewriteRule ^/blog/xml/(.+)$ /blog/item/ [R=301]

So any request to http://www.timfanelli.com/blog/linux (my old linux category), will redirect to http://www.timfanelli.com/tags/linux (my new linux tag). If I had an entry under linux named "my_entry", then the old permalink of http://www.timfanelli.com/blog/linux/my_entry.html now redirects to http://www.timfanelli.com/blog/item/my_entry.html.

Related Books

Mastering JSP Custom Tags and Tag Libraries Hip Pocket Guide to HTML 4.01: An A-Z Quick Reference to HTML Tags JSP Tag Libraries Tekken Tag Tournament (Prima's Official Strategy Guide) Professional Java Server Programming J2EE Edition

Post a Comment




About

My name is Tim Fanelli, I am a software engineer in Northern NY. I spend most of my time working, and when I can, I try to post interesting things here.

Cigar Dossiers