Collaborate without boundaries

Office 365 How to: Add search to your public facing web site with SharePoint Online - Grid User Post

Office 365 How to: Add search to your public facing web site with SharePoint Online - Grid User Post

|

 

The Grid is full of Office 365 experts that are brimming with great information. The Grid User Post blog series will expose some of The Grid's best content to the entire Office 365 Community. Are you interested in contributing to The Grid? Click here to apply.   

Our latest Grid User Post comes from   Corey Roth

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

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.

 

1 out of 1 people found this post helpful.

RSS
Comments
  • Great information, thank you for posting it!

    The challenge isn't really creating a search function-what's described here is already built in to the master page if you create public pages in SPO, so you don't need to do any of this. What's needed is a way to use SP search on the site designer built pages. The functionality is already set up-why not allow it to be used on the default public sites? Another unexpllained MSFT restriction.

  • The Grid is full of Office 365 experts that are brimming with great information. The Grid User Post blog

    mch

    can you please help me to add search to my pages then ? I have looked hi and low and the only setting i can see is to add bing search, which dosent seem to search the current site, just the web.

Page 1 of 1 (4 items)
Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Add a Comment
 
 
 
  Post