Tuesday, July 12, 2011

How to make a blogger template : the header

As mentioned in previous post on blogger template structure ,there are 4 main parts in a blogger template . Part 1 contain information on xml format ,and we can ignore this part because there's nothing to do here .
For the part 2 ,the header ,here is the first thing we should care for a blogger template .

In a default blogger template , there are only two lines in this part :
 <b:include data='blog' name='all-head-content'/>
    <title><data:blog.pageTitle/></title>

The first line
 <b:include data='blog' name='all-head-content'/>
 
will insert necessary meta tags to the header automatically . If you view source code of a page in your blogspot's blog ,what will you see ? Something like that :

 <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
<meta content='true' name='MSSmartTagsPreventParsing'/>
<meta content='blogger' name='generator'/>
.....................
There's no line  <b:include data='blog' name='all-head-content'/> .
It's replaced with meta tags , links to favicon ,link to default CSS, script file...

The next one
<title><data:blog.pageTitle/></title>
is rendered to the title tag in header
<title>blog titles .....blah blah ...</title> 

What should we do with header ?

-You can add your own meta tags for 'site description' ,'keywords' , like these :
<meta content='your blog description goes here' name='description'/>
        <meta content='your blog keywords ....' name='keywords'/>  
-Add your own favicon
<link href='link to your favicon.ico' rel='icon' type='image/vnd.microsoft.icon'/>
-Add link to outside script files or css files

A small tip

Every page in blog should have description and keywords that close to the page's content,it's what google said in their SEO tip .
In Blogger ,we can't follow this advice exactly ,but we can try our best ,by using what Blogger provide .

We can use this code in the header
<b:if cond='data:blog.pageType == &quot;index&quot;'>
<title><data:blog.title/></title>
......... meta tags for the homepage ....
<b:else/>
<b:if cond='data:blog.pageType == &quot;archive&quot;'>
<title><data:blog.title/></title>
....meta tags for category page (or archive page)....
<b:else/>
<b:if cond='data:blog.pageType == &quot;item&quot;'>
<title><data:blog.pageName/></title>
.... meta tags for single post ...

</b:if>
</b:if>
</b:if>

The code above means : 

-if the current page is homepage ,it show the meta tags for homepage in header and blog title in title
-if the current page is category page ( page that contain a list of posts under a specific category ) ,it show the meta tags for category page in header and blog title in title
-if the current page is a single post ,it show meta tags in header and title of post in title .

By using this code ,we can narrow the meta tag (keywords,page description) and title for every page type . Although we can't add keywords ,page description for a specific post ,but it's still better than do nothing ,isn't it ?
That's all for the header . In the next posts ,I will move to other parts in a blogger template , steps to make a HTML template , convert it to Blogger , and tools for this work .

No comments:

Post a Comment