Hide SharePoint lists from Search

Here is a function that will hide a list from search.  This way custom lists created won’t be included in search results.

If you notice the pages library is excluded.  You don’t usually want to hide your content pages.

public static void ListHideFromSearch(SPList listToHide)
{
//Don’t ever hide the pages library
if (listToHide.Title.ToLower() != “pages”)
{
//Hide the list from search
listToHide.NoCrawl = true;
listToHide.Update();
}
}

 

Here is a blog post about how to accomplish this same thing through the UI.

Advertisements

Got something to add?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s