January 8, 2013

show title-only search results for labels and search

Updated as of 1/7/2013: After much fiddling around, I finally got this work. I made a post about this back in 2011 and this is an entirely updated version of that post. UPDATE2 3/31/2013- if you this tweak returns only a limited number of posts, it probably means your blog has triggered Blogger's auto-pagination feature. Read more about it here.

I wanted to be able to click on a label or use the search box and have the results return only a list-- like this (this blog has also been modified so you can see what it looks like by clicking on a label or using the search box):

But I always ran into trouble implementing it. For example, sometimes I got it to work for the labels, but the search results looked like they always looked. Worse than that, sometimes, the code would effect static pages and remove all the information from the pages.

Finally, I stumbled on this post and with a little tweak, the hack seems to be working. He's updated the code to exclude very old posts, but I found that the newer code didn't work for search results. So I'm actually using his old code and I added a line to remove the dates from search results (a trick that comes up in the comments, but took me awhile to figure out so I've included that code below). If you would like to include the associated dates of each post with your search results, delete the following line from the full code below:



  • Step 1: Login into Blogger
  • Step 2: If you're in your main dashboard, use the the dropdown menu, choose 'Template' or if your blog's dashboard, just choose 'Template'
  • Step 3: Click 'Backup/Restore' and download a backup of your template.
  • Step 4: Click 'Edit HTML'
  • Step 5: click the box for 'Expand Widget'
  • Step 6: Search for this line of code (easiest is to Ctrl+F to help you find it):


    • Step 7: Replace the above code with the code below (you can just copy the code below (notice that the 1st and last lines of code contain descriptive information so you can find the code again later-- I use 'GusCode' so that's easy to locate, but you can always subsitute the text with something else)).
    • Step 8: Save the template


    The original tip cames from here...http://seoblog7.blogspot.com/2010/03/how-to-show-display-only-post-title.html?showComment=1303937321316#c8645217622353312551v

    And I thought it was exactly what I was looking for, but be careful if you opt to do this-- change your template, it changes the way the feeds look, so you'll have to reconfigure tweaks that rely on feeds.  For example, I created this blog's TOC before I tried this search tweak.  Since the tweak changed the template, the TOC no longer worked.  For now, I've left this the way it is.  But I still think returning a list of posts rather than full posts is a better search function.

    Here are the full instructions.
    • HINT#1: Make sure you check the box for "Expand Widget Templates" otherwise you won't find the right code.  
    • HINT #2: The CTRL + F that pulls up the Firefox/Chrome search box at the very bottom of the browser...
    1. Login to blogger - layout - Edit HTML - click on "Expand Widget Templates" ,
    2. Then look the code below (Tips :press CTRL + F on keyboard, and paste the code below into "Find box" of your browser): <b:include data='post' name='post'/>
    3. Delete / replace the code above, change with the code below:
    4. <b:if cond='data:blog.homepageUrl != data:blog.url'> <b:if cond='data:blog.pageType != "item"'> <a expr:href='data:post.url'> <data:post.title/></a><br/><br/> <b:else/> <b:include data='post' name='post'/> </b:if> <b:else/> <b:include data='post' name='post'/> </b:if>
    Done, save template

    No comments:

    Post a Comment