SharePoint publishing capabilities are enabled with two SharePoint features, one at the site collection level and the other at the site level. With the site collection feature activated, the publishing site templates are made available to use when creating new sites in the site collection. These site templates automatically activate the required publishing feature at the site level. In this recipe, we will create a new publishing site in an existing site collection.
The SharePoint publishing site templates will only be available for use when the SharePoint Server Publishing Infrastructure site collection feature is activated.
Follow these steps to set up a new publishing site:
Site templates in SharePoint provide instructions on how a new site is provisioned. This includes pages, features, lists, libraries, and custom provisioning handlers. The Publishing Site template activates the site scoped publishing feature and creates the libraries for a publishing site.
SharePoint sites may also be created with PowerShell and code using the server-side object model. In PowerShell, the New-SPWeb
Cmdlet has been provided for creating new SharePoint sites. In code, we add it to the collection of sites in the site collection object.
To set up a new publishing site using PowerShell, use the New-SPWeb
Cmdlet to create the site with the complete URL to the new site, the site template, a name, and a description. In addition, indicate that the site will be added to the navigation section (quick launch and top navigation) of the parent site and that the site will not inherit permissions from the parent site.
New-SPWeb -Url "http://sharepoint/publishing" -Template "CMSPUBLISHING#0" -Name "Publishing Site" -Description "A publishing site. " -AddToQuickLaunch -AddToTopNav -UniquePermissions
Follow these steps to set up a new publishing site with code using the server-side object model:
using
statement. For example:using (var site = new SPSite("http://sharepoint/"))
site.AllWebs.Add("publishing", "Publishing Site", "A site about publishing.", (uint) site.RootWeb.Locale.LCID, "CMSPUBLISHING#0", true, false);
3.15.189.199