Code, articles, tips, ideas, rants, et cetera

May 26, 2009

Change Titles of Blogger Blog for Efficient SEO

After few hours of experimenting with the Blogger template variables, I revised the template for my blog to use the following template code for generating title tags:

<b:if cond='data:blog.pageName == &quot;&quot;'>
<title><data:blog.title/></title>
<b:else/>
<title><data:blog.pageName/> | <data:blog.title/></title>
</b:if>

The title tag generated with this template code contains the post title first, followed by the blog title. This gives you search engine optimized titles as the post title is likely to contain more relevant keywords for a page than the blog title and relevant words should be placed near the beginning of title.

Secondly, I noticed that the blog.pageName variable contains valid title for regular Blogger posts and special pages such as search results, labels and archive pages. Also, in most cases the blog.pageName is same as blog.pageTitle minus blog.title. So by concatenating a few variables together, here are the titles generated by this template code:

  • Home Page
    <title>Nine-One-One... Need Code, Help!</title>
  • Blogger Search for "php gd library"
    <title>Search results for php gd library | Nine-One-One... Need Code, Help!</title>
  • Label php
    <title>php | Nine-One-One... Need Code, Help!</title>
  • Archive for May 2009
    <title>May 2009 | Nine-One-One... Need Code, Help!</title>
  • Post
    <title>Change Titles of Blogger Blog for Efficient SEO | Nine-One-One... Need Code, Help!</title>

Usage

You need to insert this code in your Blogger template as follows:

  1. Go to Blogger Dashboard › Layout › Edit HTML
  2. Backup your original template using the "download full template" option.
  3. Find the code in the Blogger template that says:
    <title><data:blog.pageTitle/></title>
    • If you cannot find it, chances are that you already have a similar hack installed. In this case, proceed if you know exactly what you are doing.
  4. Replace it with the code mentioned in the beginning of this article and save the template.
  5. Test your blog thoroughly.

Update: Change Titles of Blogger Blog That Use Classic Template

Classic Blogger templates are harder to customize. However, I have found a way to change the title for blogs that use the classic Blogger templates. The following trick changes the titles for post pages from:

<title>Blog Title: Blog Post 1</title>

to:

<title>Blog Post 1 | Blog Title</title>

The titles for other pages remain the same. Here is the template code for classic templates:

<MainOrArchivePage>
<title><$BlogPageTitle$></title>
</MainOrArchivePage> 

<ItemPage>
<title><Blogger><$BlogItemTitle$></Blogger> | <$BlogTitle$></title>
</ItemPage>

The above code should replace the existing title code for your template, which normally looks like:

<title><$BlogPageTitle$></title>

And here are the resulting titles:

  • Home Page
    <title>Blog Title</title>
  • Blogger Search for "lorem"
    <title>Blog Title</title>
  • Label php
    <title>Blog Title</title>
  • Archive for October 2009
    <title>Blog Title: October 2009</title>
  • Post
    <title>Blog Post 1 | Blog Title</title>

26 comments:

  1. Thanx salman for theses codes,they are working fine and i liked your blog design too..its very nice..

    ReplyDelete
  2. Nicely explained! Thanks for the code. I'm using it on http://inpui.blogspot.com

    However, I need your help again. I want to put a text 'news&info' after my blog title ... can you please guide me.

    Thanking you in advance.
    Nahai

    ReplyDelete
  3. Nahai, you can change the code from:

    {data:blog.title/}{/title}

    to

    {data:blog.title/} news &-amp; info{/title}

    I cannot post html code in comments so in the above code:
    * replace curly brackets with angle brackets
    * remove the dash between & and amp;


    Alternatively, you can change your blog title from blogger control panel:

    Blogger Dashboard > Settings > Title

    ReplyDelete
  4. Cool :) Check my blog for more tweaks and customiztion on for your blogger. http://alexiel-blog.blogspot.com

    ReplyDelete
  5. I tried this, but didn't work. How long does it take for the change to take effect?

    ReplyDelete
  6. The changes take place almost immediately. Try refreshing the page using CTRL + F5 or clearing the browser cache.

    Also make sure that there are no other title tags in your template except for those defined in the code.

    ReplyDelete
  7. Thanks bro...it works fine on my blog...

    http://hcier16.blogspot.com/

    i also post there this tutorial with links direct to this post...

    thanks a lot...

    ReplyDelete
  8. Hi,
    thanks for a great site. I tried the hack and have it implemented on my blog http://igotthetravelbug2009.blogspot.com but it doesn't seem to be working. If I search in google, my blog title Travelbug's blog is always first. What am I doing wrong?
    thanks

    ReplyDelete
  9. this is not that information what I am looking for.

    Can you please help us to write unique Title for "archive pages and "Label" pages.

    It will really help us a lot.

    ReplyDelete
  10. Patience, my travelbug friend... I checked your blog and it now has updated titles. You should now wait for google to index your pages again... which usually takes some time. However, you can try the following:

    1) Submit sitemaps to google
    2) Ping your sitemaps
    3) Edit your posts, change a word or two and save them. Most of the times, your blogger post is updated immediately in google index.
    4) Google for
    site:myblogname.blogger.com
    and keep an eye on indexed pages

    ReplyDelete
  11. @Amit, the generated titles for archive and label pages are OK for most people. However, if you want to customize archive page title, you can use the following condition:

    {b:if cond='data:blog.pageType == "archive"'}
    -- your archive page title --
    {/b:if}

    ReplyDelete
  12. Hi Salman,

    thanks for your help.

    I could find the way of Title optimization from official blog of blogger.

    Now it looks good.

    thanks to reply me. You are good guy.

    thanks.

    ReplyDelete
  13. Hello

    What about SEO of the home paging... when we are on the home page and we click on older posts link ... older posts load.... that page has different URL but the same title ? can we add something to the title there ? for SEO... like Page 2 | Blog Name etc...

    b/w nice post you have compiled ;)

    ReplyDelete
  14. Search engine optimizing these pages is unnecessary IMHO. Reason:

    Currently, all blogger powered blogs come with a built-in robots.txt file which you cannot edit. This file contains this instruction:

    User-agent: *
    Disallow: /search

    The older and newer post links have URLs such as these:

    http://911-need-code-help.blogspot.com/search?updated-max=2009-05-26T16%3A38%3A00%2B06%3A00&max-results=10

    These pages will not be indexed by search engines because of the above-mentioned restriction :( You can verify this through Google Webmaster Tools' Robots.txt checker.

    ReplyDelete
  15. Hey salman, you have a nice blog. And it's awesome that you know coding too! most people just copy and paste stuff :P

    Hey can you help me out with something? Check out my site http://ugabuganews.blogspot.com/
    I want to change the website title in the browser title bar but NOT the one INSIDE the website (you'll see the title written in blue on a black background as the header banner).

    I was thinking that i could do this by placing an image in the place of the header banner and changing the website title from settings. But do you know of an easier way through tweaking the code?

    I really hate the fact that both titles are chained to one entry.

    Thanks

    ReplyDelete
  16. There is more than one way of doing it. You choose which one to use:

    Method 1 -- Use CSS to hide the header that Blogger creates by default and do one of the following to create your custom header:

    (i) Insert your desired text as plain HTML inside your Blogger HTML template

    (ii) Add a HTML/JavaScript widget

    The CSS for the above blog goes something like:

    #header-wrapper { display: none; }

    Whatever new header you create, be sure to create CSS rules for that too.

    Method 2 -- Edit your Blogger html template. Be cautious and backup your template before making any change.

    i) Go to Blogger HTML template editor

    ii) Locate the line that says "b:widget id='Header1'" and delete the whole line

    In case you want it back, go to Blogger's layout > page element page, click add a gadget and choose "Page Header".

    ReplyDelete
  17. Thank you so much, Salman bhai! I really needed this for SEO-ing my blog, since the present title is pretty meaningless.

    Sorry for the belated reply though, I have been a little wrapped up in studies for sometime. That's why I am laying off blogging and other internet activities for a while. I will get back to you after I implement your suggestion. Thanks again :)

    ReplyDelete
  18. I have a Classic Minima Blogger blog. Is there some way to alter the html to do the same thing?

    Thanks

    ReplyDelete
  19. Never mind, the instructions I mentioned earlier are not going to work with classical blogger templates.

    The documentation on this page states that for title, you can use the $BlogPageTitle$ and/or $BlogTitle$ variables; and AFAIK, the behavior of these variables is not changeable.

    ReplyDelete
  20. So, I am back to square one. Thanks again for giving this a go.

    Jim

    ReplyDelete
  21. I've edited the post for you Jim :) See if the new trick helps.

    ReplyDelete
  22. Thank you for the tip you share. The XML code works well in my blog after I failed trying several times.

    ReplyDelete
  23. Un articol foarte interesant. De asemenea si blogul este frumos si am gasit o groaza de lucruri interesante. Merita sa-l adaug in bookmark. Tine-o tot asa si te voi vizita in fiecare zi. :)

    ReplyDelete
  24. This is a super useful article! I just used it to do meta refreshes for individual posts from a client's blogger to new url!

    Couldn't have done it w/out you!

    Had to change it to data:blog.url though for some reason I couldn't figure it out with blog.pageTitle


    Thanks.

    ReplyDelete
  25. @mentoring: that is a very interesting use of data:blog.url. Google seems to treat 0 second meta refresh as an equivalent of 301 redirect which is probably what you want. Smart!

    ReplyDelete

Comment moderation is enabled. Approved comments are usually published (or answered) within 48 hours.
Note: Click the "load more..." button if necessary to see all comments.