Just a query to see what the best method is for automatically enabling the sharepoint server publishing feature for new sites. Currently users are creating sites but they are unable to add the feature themselves. We use this feature to apply our custom masterpage.

I have been able to automatically enable this feature by editing the onet.xml file (15\template\site template\sts\xml) but have rolled the settings back as im not sure if this is the best method of doing so.

Any advice on the best method would be appreciated.


1 Answer 1


There are couple of options for doing this programatically:

  1. You can create you own site definition and add that feature to Site definition.
  2. Programatically activate the feature.
  3. Use powershell to activate the feature

    Get-SPWeb -Site "URL" -Limit all | % {Enable-SPFeature "PublishingWeb" -url $_.url}

    foreach ($site in $webApp.Sites) { #first enable the Publishing infrastructure feature Enable-SPFeature "PublishingSite" -url $site.url Get-SPWeb -Site $site.Url -Limit all | % {Enable-SPFeature "PublishingWeb" -url $_.url}


For more details to activate it programatically:


  • Thanks for the feedback. I will investigate options 1 and 2 further. 3 is not suitable as we want it to happen automatically. Is editing the onet.xml a really bad idea ? this seems like the easiest way and works a treat ?
    – Musti
    Commented Sep 17, 2014 at 5:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.