Sunday, January 13, 2013

Improve "Search" on Blogger

Improve your blog's search ability with this nifty code.

1.  Go into Blogger's "Edit HTML" feature and follow these instructions:

<!-- Put the following javascript before the closing  tag. -->
<script>
(function() {
  var cx = '123:456'; // Insert your own Custom Search engine ID here
  var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true;
  gcse.src = (document.location.protocol == 'https' ? 'https:' : 'http:') +
      '//www.google.com/cse/cse.js?cx=' + cx;
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);
})();
</script>
<!-- Place this tag where you want both of the search box and the search results to render -->
<gcse:search></gcse:search>

Insert the lower box <gcse:search></gcse:search> into any post.  The results will be automatic.






[Example Page]
[View Source]


Lessons:

  • Beginners:  Implement Code on Your Web Blog. 
  • Advanced:  Customize Code (choose "view source")

No comments:

Post a Comment