Most of us use Templates for third parties. Though most part of the Blogger Template looks very well, there will be some cases when a user wants to hide a particular widget or section in the post or static page or home page. The same way we can display a particular section or widget in a static page or in others parts of Blogger.

Take this case, for example, I do not want to display sidebar in Home page. Then you can give some if conditions to the sidebar section. By giving these conditions you can either hide or display sidebar in Home page. This is not only for hiding/display a particular section but you can also use CSS to change styles in different parts of page or post. Like for example when I am in the Home page I want to have these styles and when I am in a post I want to display these styles etc. i.e., varying styles in different parts of your site. Conditions below the will help you to display or hide something in Blogger.

hide or display sections and widgets in blogger

Display or Hide Sections

1. On Home Page:

Do not confuse you can display or hide anything on any part of Blogger. The following conditions can be used for displaying or hiding content or styles on the Home page.

<b:if cond='data:blog.url == data:blog.homepageUrl'>
Displays widgets/sections/styles between this tags only on homepage

The above if condition will help you in displaying required content on the Homepage. First, let us see how an if condition will work. In normal C programming, we commonly use if conditions. The syntax will be as follows:
if (condition)

If you see the above structure: condition is our requirement i.e., a < 500 or a = b and statement1, statement2 are our set of lines to execute when a condition is met. If the condition provided is true then statement1 will execute otherwise for every false condition statement2 will execute. Like the same way in Blogger also we can use if conditions for executing a set of line in particular areas.

All you need to do is place the widget or section or javascript or CSS styles in between the two tags (i.e., <b:if  cond=' '> and </b:if>). If you want to hide some section or widget or any other you can replace == with !=. Examples for both will be shown below:

<b:if cond='data:blog.url == data:blog.homepageUrl'>
<section class='section section-padding quote'><div class='container'><div class='row quote-content'><div class='col-md-8'><h2 style='color:white'>GET AN ENVIRONMENTAL QUOTE NOW</h2><p aria-hidden='true'>Saving our Environment helps our future generation in getting basic stuff from it. Overusage of resources may not show effect now, but in future ?<br/><br/> <b>PLANT A TREE&#39;S</b></p></div><div class='col-md-4 right-col'><a class='quoute-link' href=''>ENVIRONMENT QUOTE</a></div></div></div></section>

In the above example a section called Quote will be displayed on when I am in Home page and if you remove that condition then that section will display on every post and page. If you replace == with != then that section will display in all the other parts except Home page.

2. Static page:

Examples of static pages are About us, Contact us etc. Some user may want the sidebar to be hidden while for a static page. Then you can use below condition.

<b:if cond='data:blog.pageType == "static_page"'>
Displays widget between the tags only on static pages

If you want to hide something on a static page then replace == with != and place code to execute between the two tags. For example, if you want to hide the sidebar section on static pages then you can use 2nd i.e., !=. You can place entire sidebar section in between these to tags to make required changes.

3. Blog posts:

As shown above use the below tags for hiding or displaying something on blog posts.

<b:if cond='data:blog.pageType == "item"'>
Displays widget between the tags only on post pages

If you use == then the CSS style or section code placed between the if tags will execute means will be shown-up in the blog posts. If you replace == with != then the code provided between the tags will not work in posts.

4. A particular URL

If you want some code to execute only on a particular page/post by taking its URL then use below code and execution is same as above mentioned.

<b:if cond='data:blog.url = "URL of the page"'>
Displays widget between the tags only on particular pages

Those are conditions you can use to hide/display something in different parts of the Blogger. Some cases when you can use those conditions are: To follow particular styles when on the home page and some styles for a static page and some other styles for blog posts. To display or hide widgets, use the above conditions.