Wednesday, 25 June 2014

How to set title in blogger based on conditions like Label page and blog title

Introduction

This short blog post is to introduce you to set blogger title based on Label name, Post title or blog title.
If you are in this page then you know what SEO is and how you want your page to be presented to search engine. Search engines will give priority to words from left to right. So we have to order the title in such a way that the most relevant and non repeating words are on the left. Say for example: If your blog title is "xxxx" and you have created a page with title "yyyy", here you will have to show the page title as "yyyy | xxxx". Here xxxx as it is the title of the blog will be repeated on all pages, so you will have to push it to the right and have to make the page title to the left. By default blogger will display blog name to the left and then the title of the page. This will be worse on label pages where label name will not be a part of the title! This will be really annoying if you are conscious about your SEO and you have categorized your articles under some label.


Here in this post i will give the piece of code which will change your page title based on whether it is a label page, a post or blog index page.

Step 1:
Go to template edit page and Search for "<title>".

Step 2:
Now replace <title>....</title> with the code below.


<!-- Changing the Blogger Title Tag  -->
<b:if cond='data:blog.pageType == "index"'> 
  <b:if cond='data:blog.searchLabel'>
   <title><data:blog.searchLabel/> | <data:blog.title/></title>
<b:else/>
<title><data:blog.title/></title> 
  </b:if>
<b:else/> 
<title><data:blog.pageName/> | <data:blog.title/></title> 
</b:if>
<!-- Changing the Blogger Title Tag  -->

Now if you run your blog, you can see the title reflected accordingly. Now you have automated the process of telling search engine what your content is all about. Now take care of the title which you give to your post or pages.

No comments:

Post a Comment