Thursday, November 11, 2010

Restricting Blogger links to the home page

For those of you who have sites on Blogger, one of the great advantages is that you don't have to know HTML or any other programming language to have a site up and running in minutes. While you can use Blogger-supplied code (called gadgets) to add or subtract extra content into a sidebar like blogrolls, polls, or a search box, you don't usually have any options when it comes to where those widgets will be seen. Typically, once a Blogger gadget is added, you will see the content of that Gadget
in the sidebar of every page on the site.

If you have a handful of links that you only want on the home page, one option is to use the HTML/Javascript gadget (my favorite for adding plain text links) and to change how that gadget operates so that it only shows up on the home page. This involves changing the template that controls the look and feel of the site. By adding a couple of lines of code, you can change this gadget so that it is only visible on the home page.

Note:If you haven't done any kind of web site or blog coding before using HTML, and feel unsure about changing the code, either find someone who can do it for you or practice this on either one of your inactive Blogger sites or on a site that you put together for testing changes like this.

The following instructions are taking from an article on the Blogger Tricks site:
  • Sign into Blogger dashboard and click on the Design link for your blog, click on the Add a Gadget on your blog's layout, and then select the type of gadget you need (for example HTML/Javascript). Add the content that you want, and save your changes.

  • Next, you have to add a small piece of code to that gadget so that your content only displays in the Homepage. Just clcik to Edit HTML and then select the box next to 'Expand Widget Templates'. Now would also be a good time to save the template just in case.

  • Find the HTML/Javascript gadget, which should start with code that looks like <b:widget id='HTML1' locked='false' title='' type='HTML>

  • Just below that line of code, You should see a "b:includable" tag that looks like <b:includable id='main'>

  • Under that line, add the following: <b:if cond='data:blog.url == data:blog.homepageUrl'>

  • Just before the line </b:includable> tag, add the line </b:if> to close the "if" statement.

  • Save your template and test your blog. If everything went well, you should only see that gadget on the home page.
The same Blogger Tricks article also shows you how to do this for other types of gadgets, and also how to do this so that the gadget content shows up everywhere except the home page.

1 comment:

villas said...

Greatly loved the post. Will be back shortly.