After installing the Blog for Umbraco 4 package
by Tim Geyssens, I noticed that the links generated in the tags
menu were simply using query parameters instead of friendly
URLs. I would prefer them to look like this:
/blog/tag/tagname.aspx.
The good news is that Umbraco already uses UrlRewritingNet.UrlRewrite
to create friendly URLs, so everything we need to get this working
is already in place. After brushing up a bit on regular
expressions I came up with the following two step solution.
First, I added the following filter to
/config/UrlRewriting.config.
<add name="tagfilter"
virtualUrl="^/blog/tag/(.*).aspx"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="/blog.aspx?filterBy=$1"
ignoreCase="true"
/>
Then I modified BlogTags.xslt to generate the
correct URL for each tag.
<a href="{link}/blog/tag/{current()}.aspx"><xsl:value-of select="current()"/> (<xsl:value-of select="@nodesTagged"/>)</a>
There you have it. Now my tag URLs are all search
engine friendly and it only took about two minutes!