Friday 31 May 2013

Blogger Page type conditions to show hide widgets




Hello Readers, in this post we will learn how to use blogger page type conditions to show or hide widgets on particular page type. Blogger is one of the most used blogging platform around. I like blogger because you have complete control over the template code. You can make customizations with the template code, change the CSS style rules; customize the default widgets and many more. Many CMS do not give these facilities to the free users and ask for membership upgrade, but you can do all this even if you are not having a custom domain name for your blogger blog that means you need not to pay anything to avail these facilities. Sometimes you need to display or hide some widgets/content on particular page type like to display ads only on posts page. You can easily do it with the help of blogger page type conditions and later in this post we will learn about page types in blogger and how to use blogger page type conditions to show-hide widgets.

blogger page type conditions

First we shall know more about the page types in blogger. In general we have 3 types of pages in Blogger-

  • Home Page: The page appears after a user enters direct URL of your site.
  • Item Page: The page appears after the page jump or read more commonly known as Full post page.
  • Static Page: Pages like Contact Us, About Us and Sitemaps etc.

Now that you have got a hint about the different page types in blogger, we shall learn how to use page type conditions.

Note: Blogger templates are XML templates and follow a rigid structure. To Use these page type conditions you need to edit your Blogger template and it is recommended to take backup of your blogger blog before you make any customization to it.

How to use Blogger page type conditions

Page type condition for homepage:

To show particular Code/Widget only on Home page you need to enclose the specified code within the conditional code like this:

<b:if cond='data:blog.url == data:blog.homepageUrl'>
Widget Code
</b:if>

Similarly to hide any widgets on Home page, write a code like this one:

<b:if cond='data:blog.url!= data:blog.homepageUrl'>
Widget Code
</b:if>

Example:


To fix duplicate Meta description tags for your blog you should enclose the Meta description tag in the conditional code like this:

<b:if cond='data:blog.url == data:blog.homepageUrl'>
Meta Tag Goes Here
</b:if>

So that it will appear only on the home page because new blogger interface has enabled the post descriptions as well which will lead to duplicate Meta description tags. It is not good to have duplicate Meta description tags; it affects the overall SEO of your blog.

Page type condition for Item Page:

You might have seen most of the widgets on this blog are enabled only on the item or post page. I have placed social icons, ads and few other widgets on item page only because it reduces the home page loading time.

To show any code/widget on Item or Post page use this code:

<b:if cond='data:blog.pageType == "item"'>
Widget Code Here
</b:if>

To hide any code/widget on Item or Post page use this code:

<b:if cond='data:blog.pageType != "item"'>
Widget Code Here
</b:if>

Examples:

Page type condition for Static page:


Sometimes you need to disable particular widgets on static pages like comment box or ads. You can easily do it with the help of the following codes:
 
To show any code/widget on Static page use this code:

 <b:if cond='data:blog.url == "URL OF Selected Post"'>
 WIDGET CODE
</b:if>

To hide any code/widget on Static use this code:

<b:if cond='data:blog.url != "URL OF Selected Post"'>
 WIDGET CODE
</b:if>

These are the codes that you need to know for controlling your custom widgets/codes on every page type. You can also apply same method to show hide the default blogger widgets on particular page type. In the case of default blogger widgets you need to place the page type conditions after the <b:includable id='main'> of any default blogger widget but you need to know the widget id first so that you do not hide any other widget mistakenly.

I hope I have made everything clear about the blogger page types and their conditions in this article. But still if you face any problem placing any page type condition comment here. I will be glad to help you.

You should also check out the blogger tips and tricks section on our blog for more blogging and seo tips related articles. I am sure it will improve your blogging experience.

If you like my work; you can show your regards by hitting Facebook like button, following us on Google+ or Twitter, stumbling our posts on stumbleupon or giving us a link back via the links below. Stay tuned for more updates.

Do you like this post? Please link back to this article by copying one of the codes below.

URL: HTML link code: BB link code:
author pic
Author: Mohammad Zafar Ahmad
Zafar Ahmad is PHP/Java Developer and a Passionate Blogger. He likes to write about Blogging tips, SEO tips, Blogger Widgets, Smart phones, Tablets and Online Earnings. You can find him on Facebook, Twitter or Google+

5 comments:

  1. sir i created a blog on the subject delhiuptodate can you say how to get maximum people to visit my site. I have read your site but dont know how to make traffic sir can you help

    ReplyDelete
    Replies
    1. Dear first of all submit your blog and sitemap to the search engines like Google, Bing and Yahoo, then use Blog submission directories to submit your blog, use social media and youtube for promotions..I have written so many articles about blog promotions and traffic, follow them..
      Visit our Blogger tips and tricks section ..There are so many articles that will help you generate a decent traffic..

      Delete
  2. please don't tell me like this i don't know how to submit site and site map to google, yahoo and bing

    ReplyDelete
    Replies
    1. Give me your email id i will send you the posts link..

      Delete
    2. send to this mail favouriteteachers@gmail.com can u make a chance to chat with you sir

      Delete