« cheap and easy way to show "what links here" | Main | new digs »

February 28, 2005 | 19 Muharram 1426 Hijriah

using keywords and tags to help visitors find related content

Another way I'm using alternate search templates is to display lists of all entries that have the same keyword as the current entry.

To do this, I'm making use of the KeyWordList plugin, as well as the Glue plugin for formatting. The <$MTEntryKeywords$> tag displays all of the keywords as a block, but the KeyWordList plugin allows you to iterate through them separately.

Here's the code on the individual entry archive template:

<MTGlueContainer><MTKeyWordList><a href="<$MTCGIPath$><$MTSearchScript$>?Template=keyword&search=<$MTKeyWord$>&IncludeBlogs=<$MTBlogID$>&SearchField=keywords" title="list of entries tagged with <$MTKeyWord$>"><$MTKeyWord$></a><MTGlue>, </MTGlue></MTKeyWordList></MTGlueContainer>

This calls the alternate search template (see Keyword Search Template here; it's pretty straightforward), passes the individual keyword and also limits the search to the keyword field. To limit search to a specific field, you'll need to apply a hack. The Glue plugin just adds commas between the list items.


I'm actually using the Keywords field in MT more for generating "tags" that indicate the topics that I've assigned the entry to; the wording on the archive page and the listing page (search results) reflects this.

In order to get better keywords that reflect all of the important terms in the entry, I'm using the Keywords plugin, which analyzes the text and title of the entry, and any comments on it, and automatically generates keywords for the entry. The list is meant to be put in meta tags for the page where the entry is displayed, and is comma-delimited.

In order to achieve the effect I want, I'm using the Loop plugin to pull out just the words (removing the commas) and iterate through them (I could use this on MTEntryKeywords, but already had the KeyWordList plugin installed that does this specifically). This way, I can link each of the keywords separately. Then I'm using the Glue plugin to add commas back in to the list of linked keywords. Kind of silly to do it that way, but there it is.

Here's the code:

<MTGlueContainer><MTLoop values="[MTKeywords]" delimiter=", "><a href="<$MTCGIPath$><$MTSearchScript$>?search=<$MTLoopValue$>&IncludeBlogs=<$MTBlogID$>" title="search for entries containing <$MTLoopValue$>"><$MTLoopValue$></a><MTGlue>, </MTGlue></MTLoop></MTGlueContainer>

In this case, rather than using an alternate search template, I'm just linking to the regular search results page, since this is really running a search to see if there are any other entries that contain the auto-generated keywords anywhere, rather than a listing of entries "tagged with the same subject".


The whole point of this is to help visitors find other entries that are on the same topic as the current entry or are otherwise related to it. A single entry in my blog is usually not the last word on the subject. Hopefully, visitors will be encouraged to stay around and browse more of my blog if they find it easy to discover related entries. The "subject tags" are what I've decided are related; the auto-generated keywords are what a word analysis of the entry indicates are related. This may turn up connections I hadn't thought of.

Added: I added meta tags to the search templates so that search engines won't index them; however, I would recommend adding rel="nofollow" to the links that are on your individual archives as well, so that search engines don't even follow the link. Otherwise, your MT activity log will quickly be filled with search requests which are actually from Googlebot, as I discovered!

Update: It looks as though msnbot was completely out of control and caused me a lot of problems with excessive hits to my search script, even though I had rel="nofollow" in the code. Even after removing the code from my templates, I was still getting hit with several queries a minute from msnbot. I eventually renamed my search script and blocked msnbot using a robots.txt file. After this, I'll try adding the code back to my templates. Msnbot was so badly behaved that I got a warning message from my webhost telling me that my account was on probation because of excessive use of server resources. Damn you, msnbot!

Posted by Al-Muhajabah, a fully-veiled geek, at February 28, 2005 07:01 PM

Trackback Pings

TrackBack URL for this entry:

Comments

I'm new with Movable Type and have been frustrated with all sorts of things relating to customizations since I don't know how to script.

About the keywordlist plugin, I've found different versions. Does it matter which one I use? Is the file named keywordlist.pl all in lower case? Do I put it under the 'plugins' directory?

Where do I add the second code?

About the first code, do I have to have a alternate search template in place - a one just like yours - in order to use the code?

Hopefully I made my questions clear enough.

Thanks for the help

Posted by: Jacklyn Chen at March 19, 2005 08:10 PM

Hi Jacklyn,

Thanks for visiting!

I'm only familiar with the version of the KeyWordList plugin that I linked to here; if the person who developed it has come out with a more recent version than I'm using, then you would probably want to use that instead.

The name of the plugin file doesn't really matter; but it should be uploaded into the "plugins" directory with your other plugin files.

Both of the code samples that I provided are in my Individual Entry Archive template and then they link to my search script. If you're not using an alternate search template, then you would just remove the part in the first code sample that says:

Template=keyword

This is the part that tells it to use an alternate search template so if you remove it, then the default search template will be used instead.

I'm using an alternate search template just because I wanted it to look different than the regular search page, but it isn't necessary to do that.

I hope this helps.

Posted by: Al-Munaqabah at March 20, 2005 01:21 PM

Post a comment

Comment content notice: All comments to this blog are held for approval before being displayed on my site. I reserve the right to reject any comments that contain abusive or obscene language, promote racism or hatred, or link to sites that do. Also, comments that attack other visitors to the blog may be rejected. Advertising spam will be rejected: you want an ad, pay for it.




Remember Me?

(you may use HTML tags for style)