Understanding Blogger Page Types

Understanding the various Blogger page types is important if you plan to edit your own Blogger template. When you know this, then you can display certain HTML elements on specific pages by checking the page type.

In my tutorials I, at times, mention creating conditional statements that check the type of page that is displayed. This is to ensure a particular code statement is executed only for a particular type of page. Let’s look at the different page types.

Blogger Page Types

Blogger Logo

When I first started editing Blogger templates I went through some of the examples that were shown in the help system. While it does explain how the tags all come together, the help system is not comprehensive when it comes to examples.

There have been times when I wanted to only display certain elements on specific pages, such as post pages, or the homepage. To do this, I needed to understand how the page types worked within a Blogger template.

After reading the help, and checking the page types that they indicated existed, I tried editing my template to see if I could target specific pages. Sometimes the code in the template worked, while other times it wouldn’t.

I decided to then determine the page types that were associated with specific pages. To do this, I added the following code in my template:

<p><data:blog.pageType/></p>

After adding the above code, I viewed various pages in my Blogger blog and came up with the following page types:

PageType
Homepageindex
Postitem
Labelsindex
Archive – Yearindex
Archive – Montharchive

How Do I Use the Page Types?

By using the above tables, you can now place specific HTML code on specific pages. For example, to show HTML on a post page only, I would using the following code:

<b:if cond='data:blog.pageType == "item"'>
  <p>This sentence will only show on a post page.</p>
</b:if>

If you don’t want something to appear on the homepage, labels, or an archive year page, you would do something like:

<b:if cond='data:blog.pageType != "index"'>
  <p>This sentence will not show on the homepage, labels, or archive year page.</p>
</b:if>

If you want to display some text on the labels or archive year page only, but not the homepage, you would do something like this:

<b:if cond='data:blog.pageType == "index"'>
  <b:if cond='data:blog.url != data:blog.homepageUrl'>
    <p>This sentence will only show on the labels, or archive year page, but not the homepage.</p>
  </b:if>
</b:if>

As you can see, once you understand the different page types, you can customize the look of your various pages to your visitors, which can add much more appeal to your blog.

Follow Me