Table of Contents

Blogger Conditional Tags for different page types

Table of Contents

When you are designing a blogger template you want some text or components to be visible only on a specific page. Like you want a sidebar on post pages but don’t want it on the search pages. To do so in Blogger there are some conditional tags which you can use to specify different codes on different pages.

These tags help in creating your blogger blog a professional-looking website. And here we will provide you with all those bloggers’ conditional tags with proper syntax.

Syntax of blogger conditional tags:

<b:if cond='condition_expression'>
	<!-- content when condition is satisfied -->
</b:if>

List of all blogger conditional tags for all page types

Archive Pages

<b:if cond='data:blog.pageType == "archive"'>
	<!-- archive_Page -->
</b:if>

Error (404) Page

<b:if cond='data:blog.pageType == "error_page"'>
    <!-- error_Page -->
</b:if>

Homepage

<b:if cond='data:blog.url == data:blog.homepageUrl'>
<!-- homepage only -->
</b:if>

Index Page

<b:if cond='data:blog.pageType == "index"'>
<!-- index page -->
</b:if>

Item (post) Pages

<b:if cond='data:blog.pageType == "item"'>
<!-- post page -->
</b:if>

Specific Post Page By Url

<b:if cond='data:blog.url == data:blog.canonicalHomepageUrl + "2020/05/post.html"'>
<!-- A post in May 2020 -->
</b:if>

Label Pages

In blogger label represents the category.

<b:if cond='data:blog.url == data:blog.canonicalHomepageUrl + "2020/05/post.html"'>
<!-- A post in May 2020 -->
</b:if>

Specific Label Page

<b:if cond='data:blog.searchLabel == "news"'>
<!-- content of label news -->
</b:if>

Search Pages

<b:if cond='data:blog.searchQuery'>
<!-- all search pages -->
</b:if>

Search Page for Specific Query

<b:if cond='data:blog.searchQuery == "news"'>
<!-- content for search query 'news' -->
</b:if>

Static Pages

<b:if cond='data:blog.pageType == "static_page"'>
<!-- all static pages -->
</b:if>

Specific Static Page By Url

<b:if cond='data:blog.url == data:blog.canonicalHomepageUrl + "p/news.html"'>
<!-- a specific static page with name 'news' -->
</b:if>

AND/OR/NOT

AND

<b:if cond='data:blog.pageType == "index"'>
	<b:if cond='data:blog.pageType == "static_page"'>
		<!-- static page AND index page' -->
	</b:if>
</b:if>

OR

<b:if cond='data:blog.pageType == "index"'>
	<!-- static page OR index page' -->
<b:else/>
<b:if cond='data:blog.pageType == "static_page"'>
	<!-- static page OR index page' -->
</b:if>
</b:if>

NOT

<b:if cond='data:blog.pageType != "item"'>
	<!-- all pages except item pages -->
</b:if>

These conditional tags are also used to add meta information for different pages, we will learn that in a later stage.

Category
Tags

Copyright 2023-24 © Open Code