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
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:
After adding the above code, I viewed various pages in my Blogger blog and came up with the following page types:
|Archive – Year||index|
|Archive – Month||archive|
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:
<p>This sentence will only show on a post page.</p>
If you don’t want something to appear on the homepage, labels, or an archive year page, you would do something like:
<p>This sentence will not show on the homepage, labels, or archive year page.</p>
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.url != data:blog.homepageUrl'>
<p>This sentence will only show on the labels, or archive year page, but not the homepage.</p>
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.