Improve your blog SEO: add your post name to the page title

Bob Leah, over on the Social Strategist blog, brought up the excellent point of how you can improve the SEO of your developerWorks blog by displaying the right title in your browser when people look at individual posts (the <title> tag, for all you HTML geeks out there).

His approach used Javascript, which can cause problems for some search engines and can throw up some accessibility issues. I’d like to propose a different approach proposed by Dan Lowen from the IBM Interactive team. For this, the title is written onto the page by the server, not client-side.

Here’s the approach:

Open the _header template and locate this code:

<title>$utils.escapeHTML($model.weblog.name)</title>

Replace with this:

  <title>
              #if($model.permalink)
                #set($firstEntry=$model.weblogEntriesPager.entries.get(0))
                $utils.removeHTML($firstEntry.title) ($utils.escapeHTML($model.weblog.name))
             #else
                $utils.escapeHTML($model.weblog.name)
            #end
  </title>

The other main change from Bob’s example is placing the name of the blog after the post title. There are two reasons for this. If you have a long blog title, the post title gets truncated out on Google search results and on your browser tab. Secondly, Google gives prominence to the words that appear first in the title string, so adding the post title first means you have a better chance of this ranking over the name of your blog.

I hope this helps and I’m interested in your feedback.