In addition to using the SharePoint publishing site templates, publishing capabilities may be enabled on an existing site by activating the SharePoint Server Publishing feature. In this recipe, we will activate the SharePoint Server Publishing feature on an existing site.
Follow these steps to enable publishing features on an existing site:
The SharePoint Server Publishing feature creates the SharePoint libraries used for a publishing site. These include the Pages and Images libraries.
SharePoint features may also be managed with PowerShell and code using the server-side object model. The feature identifier for the SharePoint Server Publishing Infrastructure site collection feature is f6924d36-2fa8-4f0b-b16d-06b7250180fa
and the feature identifier for the SharePoint Server Publishing feature is 94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb
.
Follow these steps to enable publishing features on an existing site using PowerShell:
$featureSiteCollection = [GUID]"f6924d36-2fa8-4f0b-b16d-06b7250180fa" $featureSite = [GUID]"94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb"
Get-SPWeb
Cmdlet as follows:$web = Get-SPWeb http://sharepoint/publishing
if ($web.Site.Features[$featureSiteCollection] -eq $null) { $web.Site.Features.Add($featureSiteCollection) }
if ($web.Features[$featureSite] -eq $null) { $web.Features.Add($featureSite) }
Dispose
method to discard the SPWeb
object:$web.Dispose()
Follow these steps to enable publishing features on an existing site with code using the server-side object model:
var FeatureSiteCollection = new Guid("f6924d36-2fa8-4f0b-b16d-06b7250180fa"); var FeatureSite = new Guid("94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb");
using
statement as follows:using (var site = new SPSite("http://sharepoint/publishing"))
if (site.Features[FeatureSiteCollection] == null) site.Features.Add(FeatureSiteCollection);
using
statement as follows:using (var web = site.OpenWeb())
if (web.Features[FeatureSite] == null) { web.Features.Add(FeatureSite); }
18.221.66.185