There is no doubt that WordPress is a better blogging platform than Blogger, but this is equally true that Blogger is an Ideal Start for newbies. It is a common trend that one starts with Blogger, Gains some maturity and then switches to WordPress. There are several problems with Blogger and most of the Blogger users are those who don’t have any Technical Background For them, here is an explanation of using If Else type coding in the Blogger Template. This will enable bloggers to optimize their blog in different ways.
If Else type Conditional programing can be done by using <b:if cond=’ ‘>…..</b:if> tag. To Try this just log-in to your blogger account and move DashBoard > Layout > Edit HTML and check the “Expand Widget Templates” Option.
Now, take an objective: Lets say, we want to use different Meta tags for different pages (i.e. posts), which is not possible by any other method . Just enter the following code at the proper place:
I am sure that now you can guess the meaning of above source code. It simply says that if the URL of the page is equal to http://yourblog.com/2008/06/yourpost.html then apply the following meta tag. If you want to assign a meta tag set for the Home page of your blog then instead of using the URL of your homepage you can use data:blog.homepageUrl and your code will become like:
You can use the above conditional coding in various ways to optimize your blog. I have several suggestions for you, but you can discover more ways as per your need.
Labels:
Tricks
If Else type Conditional programing can be done by using <b:if cond=’ ‘>…..</b:if> tag. To Try this just log-in to your blogger account and move DashBoard > Layout > Edit HTML and check the “Expand Widget Templates” Option.
Now, take an objective: Lets say, we want to use different Meta tags for different pages (i.e. posts), which is not possible by any other method . Just enter the following code at the proper place:
<b:if cond='data:blog.url == "http://yourblog.com/2008/06/yourpost.html"'> <meta content='xyz,pqr' name='keywords'/> <meta content='Your Description' name='description'/> ............... </b:if>Please Replace http://yourblog.com/2008/06/yourpost.html with the actual URL of that post. You will notice that the condition is made for the variable data:blog.url and equality operator == is used. You can use some other variables and operators. The != operator is used for Not Equal to cases .
I am sure that now you can guess the meaning of above source code. It simply says that if the URL of the page is equal to http://yourblog.com/2008/06/yourpost.html then apply the following meta tag. If you want to assign a meta tag set for the Home page of your blog then instead of using the URL of your homepage you can use data:blog.homepageUrl and your code will become like:
<b:if cond='data:blog.url == data:blog.homepageUrl'> ...... </b:if>If you want to assign a meta tag set for all the post-pages (i.e., the pages other than your homepage) use this code:
<b:if cond='data:blog.pageType == "index"'> ......... </b:if>The variable data:blog.pageType looks for the type of page. Post pages are identified by item and homepage of your blog is identified by index. Hence, for homepage you can use both, data:blog.url == data:blog.homepageUrl and data:blog.pageType == “index” .
You can use the above conditional coding in various ways to optimize your blog. I have several suggestions for you, but you can discover more ways as per your need.
- Your home page will only feature the actual title of your blog, whereas post pages will feature your blog title, plus the title of your blog post. To Optimize your blog for Search Engines you need to modify it so that the past pages have titles of your blog post only. To get this done look for <title><data:blog.pageTitle/></title> and replace it with the following code
<b:if cond='data:blog.pageType == "index"'> <title><data:blog.title/></title> <b:else/> <title><data:blog.pageName/></title> </b:if>
- Similarly , sometimes you want to display some page-elements on homepage and not on post pages ( or , vice-versa ) . You can use this conditional coding again for this objective . Just Go to Page Element section and select the required page element to edit . The editor will open in a new window .Just focus on the URL of this window. At the end you can find the widgetId=HTML# . This is the widget ID of this page element . Now , switch back to the EDIT HTML section and locate that widget ( may use Find option of your browser ). You will notice a layout tag <data:content/> inside this widget code . This tag displays the contents of that page element on any page. You can do your conditional programing around this. For example you want to hide it from homepage, just do this:
<b:if cond='data:blog.pageType == "item"'><data:content/></b:if>
This trick can be used for many purposes, like displaying Ads, Featured Posts, Special Messages for visitors.
Responses
0 Respones to "Search Engine Optimization Using IF ELSE in Blogger Blog"
Post a Comment