Hiding Site Contents Link

In some scenarios, client will ask us to hide / remove the Site Content link from the Left Navigation.

To do that, instead of removing link from Navigation or css, there comes the below SPWeb object property in handy to hide the Site Contents link from the Left Navigation.

SPWeb.HideSiteContentsLink

Checkout the below snippet used to update the property to hide:

  1. Using(SPSite _site = new SPSite(“ < SharePoint Site URL > ”) {  
  2.     Using(SPWeb _web = _site.OpenWeb()) {  
  3.         _web.HideSiteContentsLink = true;  
  4.         _web.Update();  
  5.     }  
  6. }