All Blogger Conditional Tags and How to Use in your Blogger Blog

All Blogger Conditional Tags and How to Use in your Blogger Blog

All Blogger Conditional Tags and How to Use Them by Vishesh Grewal


If you are a blogger and you don't know about Blogger Conditional.
Don't worry i posted all Blogger Conditional Tags and How to Use Them.
By using conditional tags, you can specify part of your template to specific place under certain condition. Example: Using conditional tags, you can hide/show content on specific post/page/label/sidebar etc.

Blogger Conditional Tags
In this tutorial, i share all blogger conditional tags thats almost useful for blogger.


1. Conditional Tag Use

 <b:if cond='ADD_CONDITION_HERE'>ADD CONTENT HERE</b:if>
 The conditional tags syntax start with <b:if> tags and a cond attributes. Condition need to write as the value of cond attribute. Every opening  <b:if> tag need to be closed with a closing </b:if> tag.


2.  All Blogger Conditional Tags List
  • Homepage
    
    <b:if cond='data:blog.url == data:blog.homepageUrl'>ADD CONTENT HERE</b:if>
    •  Blog Post/Article Page
    
    <b:if cond='data:blog.pageType == "item"'>ADD CONTENT HERE</b:if>

    3. Index Page
    Index pages include homepage, label page, search page and yearly archive page.
    
    <b:if cond="data:blog.pageType == "index"">ADD CONTENT HERE</b:if> 


    4. Static Pages
    Static page means blogger page which we created by blogger page section.
    <b:if cond='data:blog.pageType == "static_page"'>
    ADD CONTENT HERE
    </b:if>

    5. Post and Static Pages
    
    <b:if cond='data:blog.url == data:post.url'>
    ADD CONTENT HERE
    </b:if>


    6. Label and Search Pages
    
    <b:if cond='data:blog.searchLabel'>
    ADD CONTENT HERE
    </b:if>


    7. Archive Pages
    
    <b:if cond='data:blog.pageType == "archive"'>
    ADD CONTENT HERE
    </b:if>


    8. 404 Error Page
    
    <b:if cond='data:blog.pageType == "error_page"'>
    ADD CONTENT HERE
    </b:if>


    9. First Post
    This is not for a page type. It's used for targeting the posts on multi-post pages like (index,archive,label,search query).
    
    <b:if cond='data:post.isFirstPost'>
    ADD CONTENT HERE
    </b:if>


    10. Specific Label
    Change PUT_LABEL_NAME_HERE with your label name. Label name is case sensitive.
    
    <b:if cond='data:post.labels any (l => l.name == "PUT_LABEL_NAME_HERE")'>
    ADD CONTENT HERE
    </b:if>

    Applying Conditional Tags:-

    To apply a conditional tag to a content, you need to put your content between the opening <b:if cond..>  and closing </b:if>. Example see below
    
    <b:if cond='data:blog.pageType == "item"'> 
    CONTENT (TO BE EXECUTED IF CONDITION IS TRUE)
    </b:if>

    Applying Reverse Conditional Tags:-
    If you want to reverse a conditional tag, you can do it by changing comparison operator from == (is equal to) to != (is not equal to).
    <b:if cond='data:blog.pageType != "item"'>
    CONTENT (TO BE EXECUTED IF CONDITION IS TRUE)
    </b:if>

    In the example above, the content will appear all of pages except post page. Remember that you can not apply this method to Label-Search and First Post conditionals.

    You can place all of conditional anywhere inside the template HTML. It will not work on blogger Layout like (Add a Gadget>HTML/Javascript)