Friday, January 25, 2008

Remove Adsense Ads from Home Page

Objective: Customize the template so that adsense ads will only be shown when clicked on archive, post or label. The ads will not be displayed on home page.

This is the image you will see before changes.










This is the image after you have made the changes.










You can follow the steps below to achieve this.

1)
Sign in to blogger.

2)Clik layout.

3)Go to Template.

4)Click "Edit HTML".

5)Click "Download Full Template". Save the xml file into your harddrive for backup purpose. In case problems occurred after we edited the html, you can upload back this backup file.

6)Click "Expand Widget Templates".

7)Identify the widget that you ads are in.

8)The ads widget code block should be similar to the sample code as follows.

line1.<b:widget id='HTML5' locked='false' title='Test'
type='HTML'>
line2.<b:includable id='main'>
line3. <!-- only display title if it's non-empty -->
line4. <b:if cond='data:title != ""'>
line5. <h2 class='title'><data:title/></h2>
line6. </b:if>
line7. <div class='widget-content'>
line8. <data:content/>
line9. </div>
line10. <b:include name='quickedit'/>
line11.</b:includable>
line12.</b:widget>

9) Add the following code between line2 and line3.
<b:if cond='data:blog.homepageUrl !=data:blog.url'>

10)Add the following code between line10 and line11.
</b:if>

11)This will ensure that the page element, which is wrapped between these lines, will be displayed in all pages except homepage. So your ads will be shown in all pages except the home page.

12)Test your pages if you archive your objectives.

13)If you want to remove the dots that is below your empty page element, copy and paste the following code into your template.
#HTML5 {
border-bottom: 0px;
}

14)This code will remove the border of the page element. At this stage, you should be able to remove your ads at the home page and the borders sourrounding the page element.

2 comments:

Clyde said...

Wow thank you my friend :)

HLK said...

you are welcome :)