Skip to main content

How To Create A Blog Navigation Using The Blogger Labels Widget

In this tutorial you will learn how to create a Navigation Bar using the Blogger Labels widget.



We will use the Blogger Simple template and style it using the Twitter Bootstrap 3 framework.

If you want to follow the tutorial step by step but don't know how to apply the Blogger Simple Template and integrate the Twitter Bootstrap 3 framework, you can find a tutorial here.


1.

First off all, we will remove the Blogger Navbar so that it will not conflict with the static navbar we will create in this tutorial.

If you are unsure how to do this you can find a tutorial here.


2.

We will now start editing Blogger template. Go to Template --> Edit HTML



3.

We will open a div and add a Blogger section.

Add the following code right after the opening of the body tag:

<div id="header" class="navbar navbar-default navbar-fixed-top section"> 
<b:section class='navbar' id='customnavbar' maxwidgets='1' showaddelement='no'>

</b:section>
</div>

If you have also added the Twitter Bootstrap 3 framework as suggested above your blog will now look like this:



At this point we will also remove the entire Simple Theme CSS. Remove the entire content of inside the skin tag leaving only this:

<b:skin>
<![CDATA[#Label2{margin-top:-1px}]]>
</b:skin>


4.

Now we can integrate the Labels widget into the Navbar. Add the folowing code to the Navbar you inserted at the opening of the body tag:

    <div class='navbar navbar-default navbar-fixed-top section' id='header'>
<b:section class='navbar' id='customnavbar' maxwidgets='1' showaddelement='no'>
<b:widget id='Label2' locked='false' title='Labels' type='Label'>
<b:includable id='main'>
<div class='collapse navbar-collapse navbar-ex1-collapse navbar-right' role='navigation'>
<ul class='nav navbar-nav'>
<b:loop values='data:labels' var='label'>
<b:if cond='data:blog.url == data:label.url'>
<li class="active">
<a expr:dir='data:blog.languageDirection' expr:href='data:label.url'><data:label.name/></a>
</li>
<b:else/>
<li>
<a expr:dir='data:blog.languageDirection' expr:href='data:label.url'><data:label.name/></a>
</li>
</b:if>
</b:loop>
</ul>
</div>
</b:includable>
</b:widget>
</b:section>
</div>


We will also need to ad a bit of JavaScript to remove some of the classes Blogger adds, otherwise this will interfere with the styling. We are also adding the container class to one of the divs.

  <script type='text/javascript'>
$(&#39;#Label2&#39;).addClass(&#39;container&#39;).removeClass(&#39;Label widget&#39;);
$(&#39;#customnavbar&#39;).removeClass(&#39;section&#39;);
</script>

You can add this code before the closing of the body tag.

Your Blog should now look like this:




5.

As a last step we can add the Blog Title to serve as a Home Button on the Navbar. Change the Navbar code to this:

    <div class='navbar navbar-default navbar-fixed-top section' id='header'>
<b:section class='navbar' id='customnavbar' maxwidgets='1' showaddelement='no'>
<b:widget id='Label2' locked='false' title='Labels' type='Label'>
<b:includable id='main'>
<div class='navbar-header'>
<button class='navbar-toggle' data-target='.navbar-collapse' data-toggle='collapse' style='margin-bottom:5px;margin-top:11px' type='button'>
<span class='sr-only'>
Toggle navigation
</span>
<span class='icon-bar'/>
<span class='icon-bar'/>
<span class='icon-bar'/>
</button>
<a class='navbar-brand' expr:href='data:blog.homepageUrl' style='padding:18px 15px 12px 15px;'>
<data:blog.title/>
</a>
</div>
<div class='collapse navbar-collapse navbar-ex1-collapse navbar-right' role='navigation'>
<ul class='nav navbar-nav'>
<b:loop values='data:labels' var='label'>
<b:if cond='data:blog.url == data:label.url'>
<li class="active">
<a expr:dir='data:blog.languageDirection' expr:href='data:label.url'><data:label.name/></a>
</li>
<b:else/>
<li>
<a expr:dir='data:blog.languageDirection' expr:href='data:label.url'><data:label.name/></a>
</li>
</b:if>
</b:loop>
</ul>
</div>
</b:includable>
</b:widget>
</b:section>
</div>


Your Blog should now look like this:



You can now apply your own style on top of this or keep the Navigation as is.

Please leave your questions and suggestions in the comments section below

Comments

Popular posts from this blog

iPhone 5 Rumor Roundup

Release Date The latest rumors regarding the iPhone 5 indicate that the official release date will be officially announced during the next Apple event which is to be held on September 12th 2012. According to Verizon CFO, Fran Shammo, Apple (AAPL) will stick to last year's release date and launch the iPhone 5 in October 2012. Although during the 2012 WWDC we had the opportunity to get some more details about iOS 6, no hardware specifications were released. source - 9to5mac.com Larger Screen The iPhone 5 is rumoured to have a larger, 4 inch retina display. source - Apple.pro Nano SIM According to the Financial Times, mobile carriers in Europe are stocking up on Nano SIM cards. This might be related to the release of the next generation iPhone. Smaller Dock Connector Another wide spread rumour is that Apple will release the iPhone 5 with a smaller, 8 pin dock connector. This means that new cables will be available for  new Apple devices released in the future. Did you hear any new rum...

Single Page HTML5 CSS3 Business Card Template 2.0

After seeing a huge interest in the Single Page Business Card Tutorial  i decided to create a Single Page Business Card 2.0 Template. Besides listing your title and contact details the 2.0 template also has some nice CSS3 transition effects, is available in 4 colors and the best part: IT'S FREE FOR DOWNLOAD . Demo Download CSS3 Transition Effect On hover the Name/Title block and the Contact Details blocks slide out vertically showing a centered block containing name and position, social and contact icons. Red Template Demo Blue Template Demo Yellow Template Demo Green Template Demo

HTML Codes for Romanian Characters

Character Simple Code Numerical Code Hex Code Ă &#258; &#x102; ă &#259; &#x103; Â &Acirc; &#194; &#xC2; â &acirc; &#226; &#xE2; Î &Icirc; &#206; &#xCE; î &icirc; &#238; &#xEE; Ș &#x218; &#xDA; ș &#x219; &#xDB; Ş &#350; &#x15E; ş &#351; &#x15F; Ţ &#354; &#x162; ţ &#355; &#x163;