Showing posts with label Blog Hacks. Show all posts
Showing posts with label Blog Hacks. Show all posts

December 2, 2011

Adding Link Tree / Breadcrumb Navigation Above Blog Posts

Just to increase pageviews, a blog must be designed in such a way to keep visitors busy, letting them explore parts of your site that might remain undiscovered without a design based on easy navigation. Just like the related post widget and numbered page navigation, adding breadcrumb navigation ( also called link tree) is just another way to keep your visitors engaged and stay longer on your blog. In case you don't know what link tree means, it's those links that shows where you are in a site and in blogger, it trails from the homepage down to label page and lastly, the post page you're presently viewing. You can see it right at the top of this blog post and if you can't, below is the screenshot of just how it should look.


To add this to your blog, follow these simpple steps:

1. Log in to your blogger account and click on Design ( hey, I'm still using the old interface )

2. Click on Edit HTML and check Expand Widget Template box

3. Press CTRL and F on your keyboard and search for this code:

<b:include data='top' name='status-message'/>


4. Right below that, paste this:

<b:include data='posts' name='breadcrumb'/>


There may be two occurrences of <b:include data='top' name='status-message'> in your template, you should do the same thing if there's a second one.

5. Now search for this code:

<b:includable id='main' var='top'>


6. Just above it, paste this code:

<b:includable id='breadcrumb' var='posts'>
<b:if cond='data:blog.homepageUrl == data:blog.url'>
<!-- No breadcrumb on home page -->
<b:else/>
<b:if cond='data:blog.pageType == "item"'>
<!-- breadcrumb for the post page -->
<p class='breadcrumbs'>
<span class='post-labels'>
<a expr:href='data:blog.homepageUrl' rel='tag'>Home</a>
<b:loop values='data:posts' var='post'>
<b:if cond='data:post.labels'>
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.isLast == "true"'> »
<a expr:href='data:label.url' rel='tag'><data:label.name/></a>
</b:if>
</b:loop>
<b:else/>
»Unlabelled
</b:if>
» <span><data:post.title/></span>
</b:loop>
</span>
</p>
<b:else/>
<b:if cond='data:blog.pageType == "archive"'>
<!-- breadcrumb for the label archive page and search pages.. -->
<p class='breadcrumbs'>
<span class='post-labels'>
<a expr:href='data:blog.homepageUrl'>Home</a> » Archives for <data:blog.pageName/>
</span>
</p>
<b:else/>
<b:if cond='data:blog.pageType == "index"'>
<p class='breadcrumbs'>
<span class='post-labels'>
<b:if cond='data:blog.pageName == ""'>
<a expr:href='data:blog.homepageUrl'>Home</a> » All posts
<b:else/>
<a expr:href='data:blog.homepageUrl'>Home</a> » Posts filed under <data:blog.pageName/>
</b:if>
</span>
</p>
</b:if>
</b:if>
</b:if>
</b:if>
</b:includable>


7. Now here comes the last part where you have to apply some skinning to the link tree. You can use the default one below or change it if you know a bit of css.

Search for this code:

]]></b:skin>


In the line immediately above it, paste this:

.breadcrumbs {
padding:5px 5px 5px 0px;
margin: 0px 0px 15px 0px;
font-size:90%;
line-height: 1.4em;
border-bottom:3px double #e6e4e3;
font-weight:bold;
}


Now save your template, view a blog post and you should see the breadcrumb navigation links right above your blog posts.

Further Explanation

On step 6, you need to do some editing if you're using numbered page navigation. It's not important though but I guess you might not want to see that label page get rather too long with up to 20 posts showing up. I repeat, this is only useful if you've done the numbered page navigation tweak.

Simply change 'data:label.url' to 'data:label.url + "?&amp;max-results=5"'

You should change 5 to the number of posts you set to display on a page.

November 9, 2011

Using Mobstac With Custom Domain For Blogger Mobile View

Blogger isn't that tight when it comes to mobile view, we all know that. I've been using blogger default mobile view for quite a couple of months now but I honestly don't like the look that much. I once used mobstac which I wrote about here but ditched it just because I was stuck with an address I didn't like, my blog looked like a mobstac sub-domain on mobile. Anyway, my blog is now mobilized with mobstac and I get to use a sub-domain of doncaprio.com. Cool, huh? Check out http://m.doncaprio.com and see just what I'm talking about.

Mobstac is a offers a great services that gives your blog's mobile view some life! Unlike blogger's default mobile template, you can actually edit your mobstacized site to your taste, customizing the look and feel, including the colors.


The good news about it is that you can also effectively monetize your mobile traffic by running google adsense for mobile which displays on all mobile phones. As a pro user, you can also run admob and inmobi mobile ads on your blog.

Another added advantage is that it makes it easier for your mobile users to navigate your blog a bit easier. With labels at the top of the page and some custom links added, there's a chance your mobile users will view even more pages.

How To Use Mobstac On Blogger

At first, I had some sort skepticism towards using this free service but changed my mind and saw it wasn't so bad after all. Mobstac is a site which offers a service that allows you to give your blog a nice looking mobile view and all you need to do is to register, verify your email, log in to your mobstac account and customize your blog's mobile view.

After you're done with the customization and settings, click on FAQ and view installation instructions on how to activate mobstac mobile view for your blog.

The given code should be place right under the <head> tag.

You can do this by logging in to your blog and going to Design > Edit HTML

Press CTRL + F and search for <head> and paste the your mobstac code right under it.

Save your template and try viewing your blog on a mobile browser or Opera Mini.


How To Add Google Adsense To Your Mobile Blog

You need to get your google adsense publisher ID by logging in to your google adsnes account and checking the top right corner. You should see something like pub-1234567890. Just copy the numbers out then go to the Advertising tab in your mobstac account and paste your adsense publisher ID in the appropriate box.

Using Your Custom Domain With Mobstac

Most of the tutorials online fail to cover this aspect and this is what made me lose interest in mobstac in the first place. It took me quite some time to figure out but finally, my blog automatically redirects to http://m.doncaprio.com for mobile users. Great, huh? You can have your blog's mobile version on m.your-domain.com or wap.your-domain.com, the choice is actually yours and the step is dead easy.

I assume you have a custom domain already and you definitely know what DNS records are all about, right? Your blog is already running on a custom domain with the A records and CNAME record working and you're used to making DNS entries (my assumption ;)).

You're only going to make one DNS entry to point your mobstac mobile blog to your sub-domain and then tweak your mobstac code. Interesting?

- Create a CNAME record with alias m or wap pointing to your mobstac site. If your mobstac site is http://xoxo.mobstac.com, create a CNAME with m or wap as the alias pointing to xoxo.mobstac.com, got it?

-Now go to your blog's template and locate the mobstac code you pasted earlier under the <head> tag. Found it? Good!

-Check the code carefully, you should see your mobstac site somewhere iin the middle of that code (hey, come on! open your eyes!), something like yourname.mobstac.com

-Change this to m.your-domain.com or wap.your-domain.com depending on the CNAME alias you created earlier.
-Bingo! It's done. If you did the DNS settings correctly, your mobstac site should be up and running in less than 24 hours.

Mine works quite perfectly so don't tell me it ain't working but if you've got a question or comment, don't hesitate to holler at me. Good luck!

November 3, 2011

Highlighting Blog Author's Comment In A Diferent Color (For Blogspot)

You've probably been to some blogs with blog author's comments highlighted in a color different from other comments. This hack comes with some custom templates but most templates do not have it. Whether you're using one of those blogger classic templates or a custom one, you can have your comment highlighted in a different color as the blog author. You can check my reply on this blog post to see the demo. The steps below outlines exactly how I did it.


How To Highlight Author's Comment In A different Color For Blogspot

1. Log in to blogger and go to Design > Edit HTML

2. Click the box labelled Expand Widget Template

3. Press CTRL + F on your keyboard to search for this code:

]]></b:skin>


4. In the line just before this, paste this code:

.comment-body-author {
background: #D9E4EF;
color: #000000;
border: none;
padding: 5px;
}


You can style it better by changing the color codes in red to your own desired color. The color you define here determines the color in which the blog author's comment will be highlighted.

Here comes the last and tricky part of this. Most of the tutorials on the internet do not cover this well but I took the time to finally work it out for custom templates

5.a. Search for this this code:

<dd class='comment-body'>


Right above that, paste this:

<b:if cond='data:comment.author == data:post.author'>
<div class='comment-body-author'>
<br clear='left'/>
<p><data:comment.body/></p>
</div>
<b:else/>


Now scroll a bit further down till you see this:

</dd>


Just below it, paste this:

</b:if>


The codes now should appear as shown below:

<dl id='comments-block'>
<b:loop values='data:post.comments' var='comment'>
<dt class='comment-author' expr:id='"comment-" + data:comment.id'>
<a expr:name='"comment-" + data:comment.id'/>
<b:if cond='data:comment.authorUrl'>
<a expr:href='data:comment.authorUrl' rel='nofollow'><data:comment.author/></a>
<b:else/>
<data:comment.author/>
</b:if>
<data:commentPostedByMsg/>
</dt>


<b:if cond='data:comment.author == data:post.author'>
<dd class='comment-body-author'>
<p><data:comment.body/></p>
</dd>
<b:else/>


<dd class='comment-body'>
<b:if cond='data:comment.isDeleted'>
<span class='deleted-comment'><data:comment.body/></span>
<b:else/>
<p><data:comment.body/></p>
</b:if>
</dd>


</b:if>


<dd class='comment-footer'>
<span class='comment-timestamp'>
<a expr:href='"#comment-" + data:
comment.id' title='comment permalink'>
<data:comment.timestamp/>
</a>
<b:include data='comment' name='commentDeleteIcon'/>
</span>
</dd>
</b:loop>
</dl>


If you got that right, save your template and see your comments highlighted from other comments in a diferent color.

5.b. If you're using a different kind of template and couldn't find the code specified in step 5.a., find this one instead:

<div id='comment-body'>


Just above it, insert this:

<b:if cond='data:comment.author == data:post.author'>
<div class='comment-body-author'>
<br clear='left'/>
<p><data:comment.body/></p>
</div>
<b:else/>


Scroll a bit further down till you see the closing div tag:

</div>


Just below it, paste this code:

</b:if>


When you're done, it should look as shown:


<b:else/>
<a class='comments-autor-name'> <data:comment.author/></a>
</b:if>
<a class='says'>says:</a>
</div>

<div id='comment-date'>
<span class='comment-timestamp'>
<a class='comment-permalink'><data:comment.timestamp/></a>
<b:include data='comment' name='commentDeleteIcon'/>
</span>
</div>

<b:if cond='data:comment.author == data:post.author'>
<div class='comment-body-author'>
<br clear='left'/>
<p><data:comment.body/></p>
</div>
<b:else/>

<div id='comment-body'>
<b:if cond='data:comment.isDeleted'>
<span class='deleted-comment'><data:comment.body/></span>
<b:else/>
<div style='clear:both;'/>
<p class='comment-body' style='padding-right:10px;'><data:comment.body/></p>
</b:if>
</div>

</b:if>

</div>
</div>

</b:loop>
</div>
<div style='clear:both;'/>

<b:if cond='data:post.commentPagingRequired'>
<span class='paging-control-container'>
<a expr:class='data:post.oldLinkClass' expr:href='data:post.oldestLinkUrl'>
<data:post.oldestLinkText/>



Save your template and view your blog, you should now see your comments shown in a different color. If you have any question, you're free to use the comment form below.

How To Number Comments On Blogspot

Replying to unnumbered blog comments can really be confusing especially when you can't refer to comment authors by name. More people choose to reply anonymously and but this gets easier when you can refer to them in your replies by their comment number. This blog hack works perfefectly for me as you can see the numbered comments on this blog, right? Apart from making it easier to reply, adding numbers to your blog comments gives your blog some sort of profesional look you're definitely going to like. It's quite neat, simple and easy to implement only if you follow these steps:

1. Log in to your blogger account and go to Design page and click Edit HTML. You should back up your template before you proceed

2. Mark the box named Expand Widget Template

3. Press CTRL + F on your browser to find this code:

<b:loop values='data:post.comments' var='comment'>


4. You found it? Good! Just above it, paste thispiece of code:

<script type='text/javascript'>var CommentsCounter=0;</script>


5. We're almost done now, search once again fro this code:

<b:if cond='data:comment.authorUrl'>


6. Immediately after it, paste this:

<script type='text/javascript'>
CommentsCounter=CommentsCounter+1;
document.write(CommentsCounter+".")
</script>


Now save your template and preview your blog to see the numbered comments on your blog. It's only a little piece of javascript that doesn't even affect your page load time.


This is the exact one I'm using right here and it looks cool, huh? I also suggest you read Numbered Page Navigation if you find this helpful.

October 24, 2011

How To Open Links In New Tabs (Blogger/Blogspot)

I don't expect probloggers or anyone with basic HTML knowledge to find this post particularly exciting but if you happen to be a new blogger with absolutely no idea on HTML coding, then you definitely need it. When you insert external links into your blog post, it might be just a way to drive your own visitors away to other sites without knowing. In blogger, the easy Compose mode allows you to insert external links inside your blog post but this link will open on that same page. There are two ways to prevent this from happening: using a certain HTML code while writing your blog posts or inserting a single line of code into your blog's head section.

Using HTML While Composing Blog Post

After inserting the link in compose mode normally, switch to Edit HTML mode and find the link you added.

Assuming you added a hyperlink as http://www.doncaprio.com with the anchor text being The 9ja Geek's Journal, you should see this in Edit HTML mode:

<a href="http://www.doncaprio.com">The 9ja Geek' Journal</a>

To make this very link open in a new browser tab, edit it to look like this:

<a href="http://www.doncaprio.com" target="_blank">The 9ja Geek's Journal</a>

As you can see, you only need to add a space and the piece of code shown in red after the link in Edit HTML mode.



Inserting Code In Blog Head Section

I don't like this method that much because every link opens in a new tab including labels, header links and so on. It might be useful though if you have rather too much external links on your site.

-Go to Design > Edit HTML

-Find this code:

<head>


-Right below it, paste this code:

<base target='_blank'/>


Now save your template. All links on your blog now opens in a new window/tab but I personally don't like this method. I prefer the first one but the choice is actually yours.

October 17, 2011

Display Blogger Widget/Adsense Unit At The Homepage Only

Every Widget/Gadget you add in blogger automatically shows on all pages but sometimes, you might wish to have a widget appear just on the homepage only and nowhere else. If you've noticed, there are some page elements on this site's homepage that won't appear on post pages and you can do this for ads, html/javascript or any other page element. Instead of just making the widget appear on the homepage only, you can as well make it appear on a particular post page only.

How To Make Widget/Adsense Unit Appear On The Homepage Only

To do this, you need to first know your widget ID by following the steps below:

1. Log in to blogger

2. Go to Design and locate the widget you wish to appear at the homepage only

3. Right-click on the 'Edit' below the widget and copy link location



4. Paste the link to a notepad and locate the widget ID.

For an adsense unit, it should look like this:

http://www.blogger.com/rearrange?blogID=7243280908926933904&widgetType=AdSense&widgetId=AdSense2&action=editWidget&sectionId=sidebarleft

For a HTML/Javascript widget, it should look like:

http://www.blogger.com/rearrange?blogID=7243280908926933904&widgetType=HTML&widgetId=HTML7&action=editWidget&sectionId=sidebarleft

5. Copy out the widget ID (written in the example above in red)

6. Now go to Edit HTML and check the box labelled Expand Widget Template (I suggest you always back up your template before editing your template)

7. Press CTRL + F and find the widget ID you copied earlier.

8. In the line directly below that widget ID, you should see this piece of code:



<b:includable id='main'>



9. Immediately below this, paste the code below:



<b:if cond='data:blog.url == data:blog.homepageUrl'>



10. Now scroll down a bit (maybe 5-10 lines) till you find this code:



</b:includable>



11. Just above this, paste this code:



</b:if>



The screenshot above shows what it should look like for an HTML widget.

That's it. Save your template and you'll now see the widget only appears on the homepage so far you got the steps right.

How To Make Widget/Adsense Unit Appear On Blog Post URL


The process is similar to the one above but there's a litle difference in Step 9. you only need to replace:



<b:if cond='data:blog.url == data:blog.homepageUrl'>



With this:



<b:if cond='data:blog.url == "Blog Post URL"'>



Be sure to replace Blog Post URL with the url you want the widget to appear. Save your changes and visit your blog.

How To Make Adsense Unit/Widget Display On List Pages (Homepage, Label Pages & Yearly Archive)

In step 9, use this code instead:



<b:if cond='data:blog.pageType == "index"'>



How To Make Widget Show On Post Pages Only

Use this code on step 9



<b:if cond='data:blog.pageType == "item"'>



Making Widget/ Display on Archive Pages Only




<b:if cond='data:blog.pageType == "archive"'>



Making Widget/Adsense Unit Display on Static Pages Only




<b:if cond='data:blog.pageType == "static_page"'>

100% Uptime, Unlimited Space, Unlimited Bandwidth