Langsung ke konten utama

How To Add A Featured Content Section On Your Blog's Home Page

One of the customizations I use most when designing Blogger templates is creating a "featured content" section to be displayed only on the home page. I often use this technique to display a content slider, mini-portfolio or slideshow above the main posts section.

Take a look at the home page of my site, Just Great Film, to see an example of this in action (click on images for full screen previews):

Here's an easy way to restrict the display of a gadget to your blog's home page.



Back-up your existing template

Before making any changes to the HTML code of your Blogger template, it's advisable to make a backup of your existing, working template code, just in case you make a mistake when editing or accidentally save unwanted changes!

To make a back-up of your Blogger template, simply go to Layout>Edit HTML in your Blogger dashboard and click the "Download full template" link near the top of the page.

This will prompt you to save your existing template file as an .XML document to your computer, which you could later upload if you need to restore your theme.

About "Conditional" Tags

"Conditional" template tags enable us to dictate the type of page in which the enclosed content can be displayed.

In this example, we are restricting the display to the home page only, and will be using the following syntax:

<b:if cond='"data:blog.url==data:blog.homepageUrl"'>
<--Content to be displayed on home page appears here -->
</b:if>

Anything which appears between the <b:if> tags will be displayed only on the home page. We can add any HTML content between these tags, including Blogger template tags.

If you're confident editing the template code of your blog, you can adapt the code snippet to suit your requirements. Or read on for the simplest way to add this function to your template.


The simplest way to add a featured content section on your blog's home page

If you're using Blogger's new template editor (the new format for Blogger templates) you can add a featured content section in a few simple steps:
  1. Go to Layout>Edit HTML and locate the following section of code:
    <div class='region-inner tabs-inner'>
    <b:section class='tabs' id='crosscol' maxwidgets='1' showaddelement='yes'>
    <b:widget id='Text2' locked='false' title='Some Title' type='Text'/>
    </b:section>
    <b:section class='tabs' id='crosscol-overflow' showaddelement='no'/>
    </div>

    Depending on whether you have installed a Page Links (or other) gadget, you may also see other gadgets housed within this section
  2. Add the following lines (highlighted in red) to this section of your template code:
    <div class='region-inner tabs-inner'>
    <b:section class='tabs' id='crosscol' maxwidgets='1' showaddelement='yes'>
    <b:widget id='Text2' locked='false' title='Some Title' type='Text'/>
    </b:section>
    <b:section class='tabs' id='crosscol-overflow' showaddelement='no'/>
    <b:if cond='data:blog.url == data:blog.homepageUrl'>
    <b:section class='tabs' id='crosscol-homepage' showaddelement='yes'>
    <b:widget id='HTML1' locked='false' title='Add title if you want to' type='HTML'/>
    </b:section>
    </b:if>
    </div>

    This will add an additional gadget section (beneath your tabbed page navigation, if present) in which you can add home-page-only content via the Page Elements section of your dashboard.

    I've added a placeholder gadget in this code so you can easily identify the section when editing your gadgets in the Page Elements section of your dashboard.
  3. Now preview your template: if all goes well, you should see your gadget appear in place above the posts without error and can proceed to save your template.
In order to add a gadget which only appears on the home page, go to Layout>Page Elements and edit the gadget titled "Home Page Gadget" which will appear above your blog posts. Alternatively, delete this gadget and add a new gadget as per your own requirements.


Did you find this tutorial useful?

I hope that this tutorial has explained how you can add a section to your template which will only appear on your blog's home page. Please let me know your opinions by leaving your comments below.

Komentar

Postingan populer dari blog ini

Another Blog Is Already Hosted At This Address - How To Fix

When attempting to set up their Blogger custom domain, many Blogger users have received the following error message: Another blog is already hosted at this domain Although I have set up many custom domains to use with Blogger , until this weekend I had never experienced this issue for myself (and was unable to offer any definitive solution for those experiencing this problem). My friend was experiencing this very persoalan after setting up her new blog a few days ago. We have been able to find some solutions which I hope may help others who see this error message when attempting to set up their custom domain. Assuming you have already configured the DNS settings for your particular domain provider and have attempted to publish to a custom domain through your Blogger dashboard, here are the steps you should take: 1. Publish back to your Blog*Spot domain In order to make your blog accessible while troubleshooting your custom domain, it is advisable to publish back to your Blog*Spot...

Free Blogger Backgrounds And Textures To Spice Up Your Site

Background images can instantly transform the appearance of our Blogger sites. Using the Blogger template designer, we can easily upload and configure a new background image in just a few clicks, while those using older templates need only add a few lines of code to achieve a dramatic effect. In this post, you'll find resources for hundreds of different free backgrounds, patterns and textures you can use to spice up your Blogger site, along with instructions for applying this simple but extensive effect. Large background images Large background images enable us to display a single large image behind the main content of our site, such as a photograph or complementary texture. Here is a selection of excellent resources for large background images and textures: HOT Bliggity Blog Provides a huge selection of large background images with a contrasting central panel to offer contrast for the main site content. Shabby Blogs A beautiful col...

Google Blogger For Dummies To Be Released In February!

If you're familiar with the "Dummies" series of books, you'll understand how helpful and insightful these textbooks can be in dealing with any subject. That being said, I'm happy to announce that Google Blogger for Dummies is due to hit bookshops on February 3rd. It's available to pre-order now from Amazon.com  (priced at $16.49) and will be available in Barnes and Noble, Waterstones and other bookshops, and also directly from Wiley. The author, Susan Gunelius, has been kind enough to send me a 60 page preview of this book, complete with a full and detailed table of contents and two sample chapters for my preliminary review. Also, when the book is released early next month, Susan has graciously offered me a copy of the book so that I can review it in it's entirety and offer readers my insights. What Google Blogger for Dummies will cover Being a "Dummies" guide, Google Blogger for Dummies will cover both the basics of using Blogger (crea...