Google+

Converted my blog from Blogger to Wordpress

Well I did it. I actually really liked using Blogger, and I had finally gotten my blog set up the way I liked. However, I just wanted a little more. I evaluated a couple of different solutions (including Subtext, which I use on my personal blog), and I decided to go with WordPress (the software, not the hosted service).

WordPress Logo

First off, I wanted to be able to have a little more control over some SEO aspects of my blog, such as using a robots.txt. The all in one SEO pack Wordpress plug-in seems to handle many of my requirements. Unlike Blogger, a lot of the non-content pages won't get indexed now (a good thing). See "Avoiding duplicate content with your site" for more information.

I also wanted to use the Apache mod_rewrite functionality, which is really an amazing tool. For example, I'm doing 301 redirects on all of the old Blogger archive pages, to the equivalent Wordpress archive URL's.

RewriteRule ^([d]{4})([d]{2})[d]{2}_archive.html$ /$1/$2 [R=301,L]
I also set up the Google Analtyics Plugin, which sets up some pretty neat tracking features. It's even supposed to track outgoing links, but it isn't working for me for some reason. I'll be checking with the author.

Overall, I'm very happy with the Wordpress platform. It's very simple and simply works like I would expect. Since it's one of the most popular blogging platforms, I know that support is just a Google away, and bugs shouldn't stay around too long. I also know that I can easily extend its functionality, or at least add content.

I'm hosting it on my dedicated server under Xampp. Installation of Apache, MySql, and Wordpress couldn't be easier. In fact, I had it up and running in about 10 minutes. The performance seems pretty good compared to Blogger. There are a lot less files being downloaded, which should really help. I also plan to enable gzip compression for some more speed, and I would like to get a caching plugin to avoid constant page regeneration.

Let me know what you think of the new site, and my new theme!

PS. Sorry to my RSS subscribers. When I switched to Wordpress, the RSS feed shows the posts as all being new.

Like this post? Please share it!

See a mistake? Edit this post!

Adding social tech site buttons to Blogger

ObiShawn asked me how I added the buttons at the end of each post for the social tech sites. You can look at the end of this post to see what I mean.

It's simple!

Edit the HTML for your template (Layout -> Edit HTML), click on 'Expand Widget Templates". Look for this code:

<p><data:post.body/></p>

Immediately after that code, add this:

<p><a expr:href='&quot;http://www.dotnetkicks.com/submit/?url=&quot; + data:post.url + &quot;&amp;title=&quot; + data:post.title' expr:id='data:widget.instanceId + &quot;_kickit&quot;' rel='nofollow'><img alt='Submit this story to DotNetKicks' expr:src='&quot;http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=&quot; + data:post.url'/></a>
<br/>
<script type='text/javascript'>
var dzone_url = &#39;<data:post.url/>&#39;;
var dzone_title = &#39;<data:post.title/>&#39;;
var dzone_style = &#39;2&#39;;
</script>
<script defer='defer' src='http://widgets.dzone.com/widgets/zoneit.js' type='text/javascript'> </script>
<br/>
<script type='text/javascript'>
digg_url = &quot;<data:post.url/>&quot;;
digg_title = &quot;<data:post.title/>&quot;;
digg_skin = &quot;compact&quot;;
</script>
<script defer='defer' src='http://digg.com/tools/diggthis.js' type='text/javascript'/>
</p>

That's the exact code I'm using in my template at the time of this post. It's not visually perfect, but it works.

Like this post? Please share it!

See a mistake? Edit this post!

Serving your ASP.NET .aspx pages with .html

Many SEO experts believe that Google prefers pages that end with the "html" extension. I'm guessing it has to do with the fact that static content is favored, because it is less commonly spammed. Even if Google doesn't actually look at the extension, you certainly won't be penalized for using the "html" extension.

carrying www

To support a custom extension, my first thought was to put the following code in my web.config:


<buildProviders>
<add extension=".html" type="System.Web.Compilation.PageBuildProvider" />
</buildProviders>
</compilation>

This wouldn't be a bad way to do it, if not for the fact that ReSharper doesn't like code for non-aspx files. I'm speculating that you may run into problems with other Visual Studio add-ins.

The alternative to use Server.Transfer by intercepting the requests, and transferring them to the correct page for processing.

Here is a basic example of an IHttpModule that will do the rewriting. I offer no guarantees with this code. In fact, I don't use it anywhere in production (we use a full blown rewriter solution):

public class HtmlUrlRewriter : IHttpModule
{
  private HttpApplication _context;
  private void context_BeginRequest(object sender, EventArgs e)
  {
      string path;
      path = _context.Request.Path;
      if (path.EndsWith("html", true, CultureInfo.CurrentCulture))
          _context.Server.Transfer(RewriteUri(_context.Request.Url).PathAndQuery);
  }
  public static Uri RewriteUri(Uri uri)
  {
      UriBuilder newUri;
      newUri = new UriBuilder(uri);
      newUri.Path = newUri.Path.Replace(".html", ".aspx");
      return newUri.Uri;
  }
  #region IHttpModule Members
  public void Init(HttpApplication context)
  {
      _context = context;
      context.BeginRequest += context_BeginRequest;
  }
  public void Dispose()
  {
  }
  #endregion
}

Of course you'll probably have other types of requests that you are going to be rewriting, so I recommend coming up with a URL rewriter framework, or use one of the third party options that are available.

One last note. Before IIS will allow ASP.NET to handle the processing of html files, you need to add an application extension mapping. More information about configuring IIS mappings is available here.

Obishawn also has some more information about URL rewriting and postbacks on his blog.

Like this post? Please share it!

See a mistake? Edit this post!

Jason Young I'm Jason Young, software engineer. This blog contains my opinions, of which my employer - Microsoft - may not share.

@ytechieGitHubLinkedInStack OverflowPersonal VLOG