You can hide specific elements within your Blogger template simply by utilizing the if/else statement. By learning how to properly use conditions, you can make different elements appear on different pages.
Unlike Wordpress, a Blogger template consists of a single XHTML file. This file is used to display all the pages of your blog, including the home page, each post page and listing pages, such as archives and category listings.
The issue with using a single file is that you may want to display certain elements of your blog on only specific pages. For example, you may not want to display the date on static pages, but still display it on post pages. You may also want to display specific text on your home page, but not on other pages.
While performing such actions may seem complex, it is rather simple once you understand how to use "if/else" statements in your Blogger template.
If you have done development in other programming/scripting languages in the past you are familiar with "if/else" statements. For those new to programming, let me explain how they can be used to display/hide specific content on your blog.
What is an If/Else Statement?
An if/else statement simply performs a test on a condition that you specify. If the condition is true, then certain code below the if statement is executed, while a false condition will execute the code below the else statement.
An example of an if/else statement is seen below:
<p>This is the home page!</p>
<b:else/>
<p>This is NOT the home page!</p>
</b:if>
The above code checks to see if the current page URL (data:blog.url) is the same as the home page URL (data:blog.homepageUrl) of the blog. If it is, then the condition is true, and the phrase "This is the home page!" is displayed on the page.
If the current page is not the home page, such as a post page, then the condition is false and the code below the else statement is execute. In this case, "This is NOT the home page!" is displayed on the page.
The above code also shows how you can control the displaying of content on your blog based on the type of page that is displayed. Surrounding specific lines of code in your template with the above if/else statement, you can make your home page appear different than other pages.
If you visit the home page of this blog, Blogger to the Limit, you can see how the home page looks completely different than the other pages. I use if/else statements to control what is displayed on the home page.