Skip to main content

How to Use Blogger Conditional Tags

Hey! Today I will show you how to use Bloggers' conditional tags. Blogger is one of the most used blogging platform. Almost all the services that it provides is free to use. And there are some unique functions that can make your blog standout. In this post we are going to discuss about conditional tags in Blogger. These are called conditional tags because you can use these tags under certain condition. With the help of these conditional you can give different looks to each pages and post in Blogger. You can also add a Widget that will appear in post page or in particular post. You can add any codes which will be wrapped in Blogger Conditional Tags.
Conditional Tags can be used anywhere in your Template. It means you can customize your template in any way you want. But these tags can't be used in section or in a widgetbox. Let's see the Blogger Conditional Tags.

How to Use Blogger Conditional Tags

You can see the structure of Blogger Conditional Tags in quotes below. It is made up of <b:if> tag which is the opening of the conditional tags. Cond attribute is used to specify the condition under which the texts or codes will be added. And a closing </b:if> tag. You must not forget to close the opening <b:if> tag with closing </b:if> tag. Have a look at the slight look at the Blogger conditional tag below.
<b:if cond='YOUR CONDITION HERE'>
</b:if>
Home Page
With the help of this conditional tags you can place a specific texts or your desired codes wrapped under this tag. The codes that you will add in this conditional tag of Blogger will only appear in HomePage and the entire pages, posts, labels etc. will be unaffected. You can see this tag below.

<b:if cond='data:blog.url == data:blog.homepageUrl'>
PLACE YOUR CODE HERE
</b:if>
You will have to place the code which you want to make appear in home page in place of PLACE YOUR CODE HERE in line 2.

Post Page or Item Page
This tag will help in adding codes or texts which will only appear in posts page. This tag can help you in adding different look to the posts or item page from the entire blog. See the Conditional Tag below.

<b:if cond='data:blog.pageType == "item"'>
PLACE YOUR CODE HERE
</b:if>
As I explained above you will have to place the codes or scripts in place of PLACE YOUR CODE HERE. And this conditional will add the codes in all the posts.

Labels Page
Now you may also want a particular Script or Code that will only appear in the Label Page.

<b:if cond='data:blog.searchLabel'>
PLACE YOUR CODE HERE
</b:if>
Now Place your Code or Script by replacing PLACE YOUR CODE HERE and save your Template. Now your particular code for labels page will appear.

Archive Page
With the help of this conditional tag of Blogger you can insert texts, contents, codes, scripts etc. in the archive page of your Blogger Blog and the remaining pages and posts will remain unaffected.

<b:if cond='data:blog.pageType == "archive"'>
PLACE YOUR CODE HERE
</b:if>
Add your desired codes in the specified place and save your template. After that your desired content will only appear in archive pages.

Specific Posts/Pages/URLs
This one will help you in adding particular codes or gadgets that will only appear in specific URL or specific post.

<b:if cond='data:blog.url == "PUT_URL_HERE"'>
PLACE YOUR CODE HERE
</b:if>
If you want to add Meta Keywords that will only appear in particular post than you can add the URL of that post in place of PUT_URL_HERE in the first line of above code. After that add your required codes or Scripts in place of PLACE YOUR CODE HERE in line 2.

Index Page
If you want to add the codes, content that will only appear in Home Page, Labels Page and Archive Page than this conditional tag of Blogger can help you. Take a look at the tag below.

<b:if cond='data:blog.pageType == "index"'>
PLACE YOUR CODE HERE
</b:if>
Add this conditional anywhere you want it to appear in  Home Page, Labels Page and Archive Page and place your code by replacing PLACE YOUR CODE HERE in line two.

Static Pages
Many of you may want to give little different look to your static page. This condition can help you in doing that. You can add gadgets, codes, scripts etc. that will only appear in static page of your Blogger blog. The tag is given below.

<b:if cond='data:blog.pageType == "static_page"'>
PLACE YOUR CODE HERE
</b:if>
Now you can add your required codes in the specified place.

Posts and Static Pages
If you wish to add particular gadget or content that will have to appear in Posts pages as well as Static Pages than use the conditional tag of Blogger given below.

<b:if cond='data:blog.url == data:post.url'>
PLACE YOUR CODE HERE
</b:if>
Now place the code you want to make appear in posts and static pages in place of PLACE YOUR CODE HERE and save your template. After saving your desired contents will start to appear on posts and static pages of your blog.

First Post
This is not a page of your blog. It is first post of your pages that contains multiple posts. Adding any codes under this condition will be only applicable for the first post of the multiple posts page. If you want to use this conditional tag than take a look at the tag below.

<b:if cond='data:post.isFirstPost'>
PLACE YOUR CODE HERE
</b:if>
Adding any code in place of PLACE YOUR CODE HERE in the second line will be only applicable on the first post of your multi-post page and the remaining content will remain unaffected.
Well these were the nine widely used Blogger Conditional Tags.
If you want to add alternate for the <b:if> statement than you will have to use <b:else/> tag. Take a look close look at the tag below to know how to use alternate content for Blogger Conditional Tags.
<b:if cond='data:blog.pageType == "index"'>
PLACE YOUR CODE HERE
<b:else/>
<b:if cond='data:blog.pageType == "item"'>
PLACE YOUR CODE HERE
</b:if>
</b:if>
By using the above tag you can add different tags to the index page and post/item page. By using this tag the codes will display in posts page and index page of your blog. Placing the code in place of red text will make your code in index page and if you will place the codes/content in place of blue text than that code which you added in place of blue text will appear in post page.

Until now you have seen how to add particular code in each page of blogger using conditional tags of Blogger. But you can also reverse the process. It can be reversed by replacing == with != Take a look at the code below to understand
<b:if cond='data:blog.pageType != "item"'>
PLACE YOUR CODE HERE
</b:if>
If you will place the code in place of PLACE YOUR CODE HERE using above conditional tag than the code which you added in place of PLACE YOUR CODE HERE using above conditional tag for Blogger will appear in every page of your blog except the item page/post page of your Blogger blog. You can clearly see that the process is reversed by replacing == with != in the conditional tag. You can replace == in every conditional tag in this post with != to reverse the process.

That's All about the use of Blogger Conditional Tags. I hope you enjoyed reading the post. If you are facing any problem in implementing these conditional tags on your Blogger blog than feel free to ask me or you can also place a comment below.

Comments

Popular posts from this blog

Need for Speed (NFS) Carbon Cheats, Codes and Unlock Parts

Need for Speed makes some great racing games like NFS Most Wanted, Rivals etc. and Need for Speed Carbon is another 10th addition to their NFS series. It's the first game to get the PEGI rating 12+. It's a very good game with it's story line. If you are looking for some adventure and a good racing than this one will be in your game list. While playing the game you will face some difficulty in completing this game. And from than onwards you may look some cheat codes that can help you in completing NFS carbon. And to make it easier for you here is the list of some working cheat codes and trainer. But you proceed to know about cheats and tricks for Need for Speed Carbon you would like to know the adventurous story of the game. So let's start. The game is set in the fictitious city of Palmont. Soon after the player leaves the Rockport City ( remember jumping of an old bridge in last scene of NFS Most Wanted) the player drives on a route to Palmont city with his BMW ca...

How to Watch Any TV Show or Movie on Kodi

Kodi is a cross-platform media center solution developed by XBMC/Kodi Foundation, a non-profit technology association. Kodi which was previously known as XBMC has been growing rapidly from last few years. While the application offers to play local media files, but, it has plethora of third party add-ons, which, we can use to increase it's usefulness. In this post, you'll learn the process to install Indigo and Exodus on Kodi 18 (64-bit). The process is similar on version 17 of this app, however, I haven't checked the previous versions. Note : Streaming copyrighted content is illegal, nevertheless, it's completely legal to use Kodi for viewing the content you've purchased. First, we'll need to add Indigo Installer. Follow the following steps to know how to do it: Open Kodi . Click on the Gear button (settings). Select File Manager . Double Click on Add Source . Click on <None> ... ...type  http://fusion.tvaddons.ag and...

Top 5 Alternatives to Extratorrent

In an unforeseen move, Extratorrent decided to shut down few months ago. It was one of the most popular torrent site, but now users who visit it's homepage are greeted with a message which clearly states they are not going to return in the future. Now that they are gone, various clone sites such as extratorrent.cd has been setup to squeeze money from the confused visitors via its advertisements. People visiting these clone sites should know that the original ExtraTorrent owners have deleted all data, and none of the impostors have access to the old ExtraTorrent files. There are many alternatives out there. You just need to look at the right place. Take a look at the following original torrent sites which might entice you. 1337x.to 1337x is probably the best designed torrent site you'll ever come across. Although it lacks the ExtraTorrents' rating system, nonetheless, most of the contents are verified by moderators. The site has easy-to-navigate subsections whic...