Add Custom Search to a Sharepoint Online 2013 Blog Site

Planet Microsoft.
Sometimes I think Microsoft must be living on a different planet. They provide a useful blog site template with a lot of built in functionality and enough flexibility to allow it to be used in a variety of ways – not just as a blog. But the out of the box search function uses a results page located in the dreaded _layouts directory that prohibits any customization. That’s okay if you’re not customizing your blog site, but I find it hard to believe anyone would consider the dreadful out of the box blog styling acceptable for a serious enterprise intranet or public site.

Searching for the right search.

So if you customize your blog site’s look, how do you fix the search results page so it looks like it belongs to the same site and doesn’t revert to the appallingly bland default /_layouts/15/osssearchresults.aspx page?

After a lot of googling and a series of frustrating and failed attempts to play with master pages and page layouts, I hit upon a very easy solution. Instead of trying to force the site’s framework onto the search results page, insert the search into the site. Here’s how I did it:

How to

  • First I made a copy of the post.aspx page.
  • I renamed it search-results.aspx. (You can either delete or hide the default web parts on the page).
  • I opened the page in edit mode and inserted a search results web part.
  • I then opened the site settings > search > search settings.
  • And specified the page results should be sent to.

search1

 

Refine your search.
That alone connects your site’s search box to the results web part on the designated page. Which is pretty cool.It does however return everything in the site collection index – a lot of which may be irrelevant. My thinking is if someone is searching a blog they probably only want to see relevant posts in that blog. So I refined the results as follows:

Open the new search results page and edit the results web part’s properties.
Click change query.
Change the “select a query”, “restrict by app” and “restrict by content type” settings according to the image below.

search3

That will only return relevant posts. Of course you can vary that schema depending on your own desired results. And the end”result” is this – regular post page on the left and search results page on the right:

search4

 

So there you go – a quick and easy way to use built in functionality to do what Microsoft should have already done for you! Hard to believe how simple this really is – and harder to believe why Msft doesn’t do a better job of documenting simple answers like this to common questions.

Questions?

Visit my forum » if you have any questions. For development work, you can contact me here ». And if you think this would be useful to others, feel free to share it by clicking one of the share buttons up top!