Blog Engine .NET Tag Cloud Optimization

For all of the amazing blogs and websites that are out there, hundreds exist that are just average. Most of us are not experts, like Eric Lippert, who can write with authority on a single topic for years and have interesting and new things to say. Instead, there are blogs like mine. I write about whatever is interesting to me at the time. As the years progress, what I write about changes, and I want my website [Blog Engine .NET] to reflect that.

As I create new posts, they are shown on the front page till they get old. However, I have found that the default Tag Cloud widget is only interested in what I have written about most. For example, I took a motorcycle trip with my brother, so I wrote extensively about it. Since that trip almost two years ago, Arkansas was the top item on my Tag Cloud. I have nothing against that wonderful state, but I felt that it made my website out of date.

I have made a simple one line code change to the Tag Cloud that makes it more relevant. Instead of using tags from all 190 posts on my site from the last 2 years, I changed it to only consider tags from posts that are less than 1 year old. After this change was made, the Tag Cloud immediately updated and more accurately reflected what I have been writing about recently.

Now for the details, I’ll assume you’re familiar with Blog Engine .NET:

1. This example is using version 2.0, I have not tested it with other versions.
2. Go to the file (from the root of the source code download) BlogEngine.NET\widgets\Tag cloud\widget.ascx.cs
3. Using your favorite text editor (because we don’t need to compile anything) go to line 197.
  a. Method private static SortedDictionary<string, int> CreateRawList() method
      The old method

foreach (var tag in Post.Posts.Where(post => post.IsVisibleToPublic

With a minor modification highlighted, we can adjust the time to just the last year’s worth of posts.

4. With the minor change in the method, save the file, and upload it to the same relative path on your Blog Engine .NET installation and next time you call a page with the Tag Cloud on it, it will automatically re-compile and the cloud will be up to date.

Sorry that I used images instead of text, but I wanted the color to come out nice. If you’re nervous to make the code change yourself, you can download the one file to install yourself. (1.84 kb)

Happy Coding!

Hogan Haake

Getting rid of SPAM comments in BlogEngine.NET

I have been running this website on BlogEngine.NET version for over a year now. I like the interface and the familiar .NET coding environment. One of the biggest drawbacks to this blog software is the proliferation of SPAM comments that are entered on my site. I began to take for granted that I would never get rid of them. Every a few days, I got notified that there was a new comment on a post I made. Nearly every post was SPAM. I decided it was time to fight back. I didn’t want to loose control of the comments to a third party, or invent/borrow my own captcha system. Some day it may be necessary, but I don’t particularly like them. When I looked at my web logs for the site, I noticed that there were several searches for “powered by” and then some random term.

And they found my page because the footer of the page looked like the following

This got me thinking. I’m using the standard theme (Indigo) provided during installation of I decided to try modifying the master page for this theme. Once I modified the theme, I have stopped getting SPAM comments to my site. If you’re interested, you should do the same.

1. Download the file /themes/Indigo/site.master
2. Change the text on line 64 FROM

<div class=”footer”>
        Powered by <a href=”” target=”_blank”>BlogEngine.NET</a> <%=BlogSettings.Instance.Version() %> |
        Original Design by <a href=””>Arcsin</a>, Adapted by <a href=””>RazorAnt</a>

To something like

<div class=”footer”>
    Thanks for visiting

Then re-upload the site.master page and your site will have something like

Give it a try, but you might not be happy with the results. Now that I changed the text, I don’t have any comments on my entries. Now to get more traffic to my site!