Is this for you?
How blogger works ?
When we submit the template XHTML code to the blogger it is stored in the blogger database. When the blog is requested via a browser, the Blogger Parser parses the code and sends back the HTML output of the parsed XML code which will be displayed in the browser.
The Basic Layout
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'> <head> <title><data:blog.pageTitle/></title> </head> <body> <!-- BODY CONTENTS --> </body> </html>
Blogger template is fully coded in XHTML and Blogger Elements. In the above code we have defined a set of xmlns (XML Namespace) which are defined by Google for use with blogger. Namespace such as
xmlns:b, xmlns:data, xmlns:expr lets us design our blogger web page and also to get data from the blogger database.
xmlns:b– access the blogger elements
xmlns:data– is where the data of the blog comes from
xmlns:expr– is used to calculate expression for attributes(will see this soon).
Note: You can change the above namespace name from
d at anytime. But it’s best to stick with what is default.
Before you continue – Skip This
Before moving along, have a brief layout of how your blog should look. Sketch a layout of your blog’s structure. Take a piece of paper, start drawing the layout or you could use apps like lucidchart and wire-frame the design that you want your blog to be. Identify elements like,
- Where should the menu come and how should it look.
- How will the posts appear, is it a 2 column or 3 column layout.
- Where should the widgets appear etc.
The Blogger template layout is designed with Sections. Sections are the one’s which makes the layout of the web page(like header, footer, sidebar etc.). It is like the sections in HTML5.
Above image shows some sample web page layouts which will give you an idea of what a section of a web page might be.
The syntax to create a section in blogger is shown below. There can be any HTML code around the section code, but there can’t be any HTML inside the section code. To define the contents of the section we must use the Widget element in blogger, which will be discussed shortly.
Each section tag has the following syntax, which is similar to an HTML element with attributes.
<b:section id='' class='' maxwidgets='' showaddelement=''> </b:section>
Each attributes have different meanings, that will be parsed by the blogger to render the elements final output.
- id(Required) – A unique name, with letters and numbers only.
- class(Optional) – Common class names are ‘navbar,’ ‘header,’ ‘main,’ ‘sidebar,’ and ‘footer.’ If you switch templates later, these names help Blogger determine how best to transfer over your content. However, you can use different names, if you like.
- maxwidgets(Optional) – The maximum number of widgets that can be added in this section. If you don’t specify a limit, there won’t be one.
- showaddelement(Optional) – Can be ‘yes’ or ‘no,’ with ‘yes’ as the default. This determines whether the Page Elements tab will show the ‘Add a Page Element’ link in this section. Have a look at the image shown below,
- growth(Optional) – Can be ‘horizontal’ or ‘vertical,’ with ‘vertical’ as the default. This determines whether widgets within this section are arranged side-by-side or stacked.
A section can contain widgets. It can not contain other sections or any other code. If there is a need to add a code around or inside a section, the section must be separated into two different sections.
<b:section id='header' class='header' maxwidgets="1" showaddelement="no"> <!-- Section contents --> </b:section> <b:section id='main' class='main' maxwidgets="1" showaddelement="no"> <!-- Section contents --> </b:section> <b:section id='footer' class='footer' showaddelement="no"> <!-- Section contents --> </b:section>
Note: By default there must be at least two b:section tags or else blogger will throw an error.
Sections are made mainly using widgets. Sections are just layout elements, widget is with which the real data is displayed. A widget at its simplest form, is just a single tag, which is a placeholder for what should appear in the page element. There are some default widgets available in blogger and a custom widget can also be created. The data for the widget is stored in the blogger database and is accessed only when the widget is to be displayed.
<b:widget id='' locked='' mobile='' title='' pageType='' type='' />
- id(Required) – May contain letters and numbers only, and each widget ID in your template should be unique. A widget’s ID cannot be changed without deleting the widget and creating a new one.
- type(Required) – Indicates what kind of a widget it is, and should be one of the valid widget types listed below.The various widgets types are,
- locked(Optional) – Can be ‘yes’ or ‘no,’ with ‘no’ as the default. A locked widget cannot be moved or deleted from the Page Elements tab.
- title(Optional) – A display title for the widget. If none is specified, a default title such as ‘List1’ will be used.
- pageType(Optional) – Can be ‘all,’ ‘archive,’ ‘main,’ or ‘item,’ with ‘all’ as the default. The widget will display only on the designated pages of your blog. (All widgets display on the Page Elements tab, regardless of thier pageType.)
- mobile(Optional) – Can be ‘yes’, ‘no,’ or ‘only’ with ‘default’ as the default. This decides if the widget will be displayed on mobile or not. Only Header, Blog, Profile, PageList, AdSense, Attribution will be displayed on mobile when the mobile attribute is ‘default.’
<b:section id="sidebar" class="sidebar" maxwidgets="" showaddelement="yes"> <b:widget id='CustomSearch1' title='Search' type='CustomSearch' locked='false'/> <b:widget id='FollowByEmail1' title='Follow By Email' type='FollowByEmail' locked='false' /> <b:widget id='PopularPosts1' locked='false' title='Popular On Relatemein' type='PopularPosts'/> <b:widget id='Label1' type='Label' locked='false' /> </b:section>
The Syntax and Documentation is taken from the Official Blogger Documentation