What are Conditional Tags in Blogger
Conditional template tags in Blogger template allows you to specify a part of your template code on specific types of pages or specific URLs.
One practical application could be to display a widget on specific pages. You can hide sidebar on some pages, apply a meta tag to certain page or whatsoever. Complex Blogger templates make large use of these conditional tags. In this post, I'll show you the possible conditional tags and their example usage.
A conditional template tag in Blogger looks like following
<b:if cond='condition_expression'>
<!-- content when condition is satisfied -->
</b:if>
Conditional Tags On Home Page
Modern Version
<b:if cond='data:view.isHomepage'> … </b:if>
Primitive Version
<b:if cond='data:blog.url == data:blog.homepageUrl'> … </b:if>
Conditional Tag on the Index Page
Modern Version
<b:if cond='data:view.isMultipleItems'> … </b:if>
Primitive Version
<b:if cond='data:blog.pageType == "index"'> … </b:if>
Conditional Tag on the Item Pages
Modern Version
<b:if cond='data:view.isSingleItem'> … </b:if>
Primitive Version
<b:if cond='data:blog.pageType in ["item", "static_page"]'> … </b:if>
Conditional Tag on the Post Pages
Modern Version
<b:if cond='data:view.isPost'> … </b:if>
Primitive Version
<b:if cond='data:blog.pageType == "item"'> … </b:if>
Conditional Tags on Static Pages
Modern Version
<b:if cond='data:view.isPage'> … </b:if>
Primitive Version
<b:if cond='data:blog.pageType == "static_page"'> … </b:if>
Conditional Tag on the Label Page
Modern Version
<b:if cond='data:view.isLabelSearch'> … </b:if>
Primitive Version
<b:if cond='data:blog.searchLabel'> … </b:if>
Conditional Tags on Archive Pages
Modern Version
<b:if cond='data:view.isArchive'> … </b:if>
Primitive Version
<b:if cond='data:blog.pageType == "archive"'> … </b:if>
Conditional Tags on Search Page
Modern Version
<! - Includes label search page ->
<b:if cond='data:view.isSearch'> … </b:if>
<! - Just the search page ->
<b:if cond='data:view.isSearch and !data:view.isLabelSearch'> … </b:if>
Primitive Version
<b:if cond='data:blog.searchQuery'> … </b:if>
Conditional Tag on Error Pages / Error 404
Modern Version
<b:if cond='data:view.isError'> … </b:if>
Primitive Version
<b:if cond='data:blog.pageType == "error_page"'> … </b:if>
Conditional Tags on Preview Page
Modern Version
<b:if cond='data:view.isPreview'> … </b:if>