As
you have probably observed, all the widgets/gadgets you add to your
blog, will be displayed in all the pages by default, including your
homepage too. And if you haven't heard about this already, Adsense can
disable your account only for the reason you've put ad units on the
content of your contact or privacy policy pages. Isn't that ridiculous?
Well, if you ask me, the answer would be: yes and no. First of all, lots
of widgets can make a blog/site to look unprofessional, increasing page
loading time, therefore visitors will lose their patience.
To hide (or show) widgets in particular posts, static pages, homepage or archive pages, you can use conditional tags.
1. First of all, go to Blogger's Dashboard >> Design >> Page Elements and give a name for the HTML/Javascript gadgets you have already added. Doing this it will be easy for you to identify the widgets in your blogger template. Give it a unique title so that it does not match with any of the titles of other widgets added.
2. Then go to Dashboard >> Design >> Edit HTML and check the "Expand Widget Templates" box.
3. Find your widget in the HTML by using Ctrl+F and entering the widget's name in the search box. Let's say i have given the title for my widget as "Recent Posts". After searching you will find the below snippets:
This code represents the widget/gadget that you have added in the Page Elements location. All you have to do is to add the following conditional tags marked with red just below and above to hide the widget from specific pages or posts in Blogger. Let's see some examples:
To show the widget only in Homepage:
To show Blogger widget only in post pages
To show the widget in a specific page
Note: Replace URL of the page with the address of the page in which you want the widget to appear
To hide a widget only in a particular page
To show widgets only in static pages
To hide widgets in Static Pages
To show widgets only in Archive Pages
After you have added the conditional tags, Save Template and view your blog.
That was all ;)
To hide (or show) widgets in particular posts, static pages, homepage or archive pages, you can use conditional tags.
1. First of all, go to Blogger's Dashboard >> Design >> Page Elements and give a name for the HTML/Javascript gadgets you have already added. Doing this it will be easy for you to identify the widgets in your blogger template. Give it a unique title so that it does not match with any of the titles of other widgets added.
2. Then go to Dashboard >> Design >> Edit HTML and check the "Expand Widget Templates" box.
3. Find your widget in the HTML by using Ctrl+F and entering the widget's name in the search box. Let's say i have given the title for my widget as "Recent Posts". After searching you will find the below snippets:
<b:widget id='HTML1' locked='false' title='Recent Posts' type='HTML'>
<b:includable id='main'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != ""'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>
<b:include name='quickedit'/>
</b:includable>
</b:widget>
This code represents the widget/gadget that you have added in the Page Elements location. All you have to do is to add the following conditional tags marked with red just below and above to hide the widget from specific pages or posts in Blogger. Let's see some examples:
To show the widget only in Homepage:
<b:widget id='HTML1' locked='false' title='Recent Posts' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url == data:blog.homepageUrl'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != ""'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>
<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>
To show Blogger widget only in post pages
<b:widget id='HTML1' locked='false' title='Recent Posts' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.pageType == "item"'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != ""'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>
<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>
To show the widget in a specific page
<b:widget id='HTML1' locked='false' title='Recent Posts' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url == "URL of the page"'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != ""'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>
<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>
Note: Replace URL of the page with the address of the page in which you want the widget to appear
To hide a widget only in a particular page
<b:widget id='HTML1' locked='false' title='Recent Posts' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url != "URL of the page"'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != ""'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>
<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>
To show widgets only in static pages
<b:widget id='HTML1' locked='false' title='Recent Posts' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.pageType == "static_page"'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != ""'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>
<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>
To hide widgets in Static Pages
<b:widget id='HTML1' locked='false' title='Recent Posts' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.pageType != "static_page"'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != ""'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>
<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>
To show widgets only in Archive Pages
<b:widget id='HTML1' locked='false' title='Recent Posts' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.pageType == "archive"'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != ""'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>
<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>
After you have added the conditional tags, Save Template and view your blog.
That was all ;)
0 comments:
Post a Comment