Office 365 How to: Add search to your public facing web site with SharePoint Online

Posted Thursday, July 21, 2011 10:24 AM by CoreyRoth

During the Office 365 beta, I wrote a post about how to create a public facing web site with SharePoint Online.  This gives you a simple site that you can then begin to customize to your needs.  However, many people have said they found it lacking.  The site actions menu particularly frustrates people. However it’s easy to get around by simply going to the page /_layouts/settings.aspx.

I’m currently working on a Search talk with SharePoint Online for SharePoint Conference 2011 (#SPC11) and I got to thinking last night about how search works with a public facing web site.  The answer is, out-of-the-box, it doesn’t.  There is no search box on the home page nor is there a search center.  This post will teach you how to add search functionality but it won’t cover any of the branding aspects.  Creating a Search Center is relatively easy, just click on the Member Login link and then click All Site Content.  From here we can click the Create button to create our search center.

SPOPublicFacingNewSearchCenterSite

From the list you see above, Basic Search Center is our only option.  You can likely get the Enterprise Search Center template listed as well by activating the Publishing Infrastructure feature on the site.  However, we’ll just use a Basic Search Center though as it will suit our needs.  With on-premises solutions, I typically give my search centers a URL of /search.  However, for some reason SharePoint Online doesn’t allow it in my environment and I get the following error.

“Search” cannot be used as a site name.  Site names cannot contain certain reserved words and cannot begin with an underscore.  Please enter a different name.

SPOPublicFacingSearchCenterError

I’m not sure if this is specific to my environment or not.  On the private site collection site, I have a search center at /search and it works fine.  Maybe that’s the issue, I don’t know.  Any how, to resolve it I just went with my backup URL of /SearchCenter and it worked fine.  After you create the site, you should have a site that looks like the one below.  Again it won’t have the master page or the styling as the rest of your site.  That’s up to you to customize later.

SPOPublicFacingSearchCenter

Let’s try out a query.  I’ll search for the term “Home”.

SPOPublicFacingSearchCenterHomeResultsNoScope

Look!  We get results!  It works!  Oh wait, after further examination, it gives me results for both my public facing and private site collection.  You might be thinking that’s bad, but in reality it’s working exactly as intended.  Search returns all results for your tenant that you have access to.  Since I was logged in, I get results from both sites.  What if I am not logged in though does search still work?  The answer is yes.  I opened a new browser windows with Google Chrome’s Incognito feature to force myself to sign out and here is what we get.

SPOPublicFacingSearchCenterHomeResultsNoScopeLoggedOut

As you can see it now only shows results from the public facing web site.  Notice the Sign In link at the top right.  The beauty of talking about SharePoint Online though is that I can actually provide links to the site and you can try it yourself.  Execute the above query yourself by clicking here.  That link may not be good forever.  It should work though as long as I haven’t torn down the site, let my account expire, or used all of my resources.

What if we want to truly separate out the Search Results?  For example, you want your users to be able to be logged in but still only see the content from the public facing web site.  We can do that with a scope.  In SharePoint Online, scopes must be created at the Site Collection level.  Again go to /_layouts/settings.aspx and then click on the Search Scopes link.  Here, click on the New Scope link and give your scope a name.  In my case, I chose the name Public.  You may consider changing some of these other settings here later, but for now, I went with the default.  After you create it, you need to add a scope rule.  For Scope Rule Type, choose Web Address.  For Web Address, choose Domain or subdomain and then enter the domain of your site (minus the http://).  In my case, I entered dotnetmafia-web.sharepoint.com.  Lastly, for the Behavior radio button choose Require.  Here is what the screen looks like.

SPOPublicFacingNewScopeRule

After you create the scope, you have to wait for a scope update.  Unfortunately, this can take a while (as shown below) and there isn’t a button for you to click to force the update to occur now like with on-premises SharePoint.

SPOScopeUpdate

Once it occurs, try out a simple query using the keyword syntax on our existing search center.  I wrote a post on useful keywords to use in search a while back that describes the use of the Scope keyword as well as others.  I issued the following query.  Try it out for yourself.

home Scope:”Public”

SPOPublicFacingSearchCenterHomeResultsManualScope

Now that works great.  Obviously, we don’t want our users to have to type the scope in themselves though.  What we’ll do is set the scope property on the CoreResultsWebPart of the results.aspx page.  This will force all queries in that search center to use that scope and give us the results we want.  Edit the page, and then edit the CoreResultsWebPart.  Under Location Properties, type the name of your scope in the Scope box. 

SPOCoreResultsPropertiesScope

When you are finished, click Ok, and then save your page.  When you are done, issue a query again without the Scope keyword and you should get the desired results. 

SPOPublicFacingSearchCenterFinal

Like before, you can try the above query out yourself on my SharePoint Online site.  You now have a working search.  However, I wanted to point out one more potential issue.  On your Site Settings page, click on the Search Settings link.  Make sure it has the correct URL to your search center on the public facing site.  I have seen issues before where it was pointing to the private site collection.

SPOSiteCollectionSearchSettings

At this point, you may want to customize the way your search center looks by applying a custom master page and what not.  It’s also up to you on how you want to get your users to the search center.  You can add the standard Search Box delegate control to your master page if you like.  You can also just provide a simple link to Search as well.  I’ll leave those items to the branding experts (I’m definitely not one of them :) ).  The links to my SharePoint Online site should work for a while and I’ll update them later if necessary.

Comments

# SharePoint Daily » Blog Archive » Microsoft 4Q Earnings Reports; New Bing UI on the Way; Gaming in the Cloud

Pingback from  SharePoint Daily  » Blog Archive   » Microsoft 4Q Earnings Reports; New Bing UI on the Way; Gaming in the Cloud

# Microsoft 4Q Earnings Reports; New Bing UI on the Way; Gaming in the Cloud

Friday, July 22, 2011 8:15 AM by SharePoint Daily

When it is this hot outside, is it OK to have ice-cream for breakfast? --Chris Top News Stories Microsoft

# Office 365: Links Worth a Look for Friday, August 12th, 2011 « My Central Admin

Pingback from  Office 365: Links Worth a Look for Friday, August 12th, 2011 « My Central Admin

# re: Office 365 How to: Add search to your public facing web site with SharePoint Online

Thursday, August 30, 2012 9:35 AM by Steph

Wow, thanks so much for this, really appreciate it, just managed to get it going for a new customer. Now for the stylising!

# Microsoft 4Q Earnings Reports; New Bing UI on the Way; Gaming in the Cloud – Bamboo Solutions

Pingback from  Microsoft 4Q Earnings Reports; New Bing UI on the Way; Gaming in the Cloud – Bamboo Solutions

Leave a Comment

(required) 
(required) 
(optional)
(required)