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.
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.
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.
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.
Labels Page
Now you may also want a particular Script or Code that will only appear in the Label Page.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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'>Home Page
</b:if>
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"'>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.
PLACE YOUR CODE HERE
<b:else/>
<b:if cond='data:blog.pageType == "item"'>
PLACE YOUR CODE HERE
</b:if>
</b:if>
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"'>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.
PLACE YOUR CODE HERE
</b:if>
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
Post a Comment