By default, when you trying to activate the SharePoint Server Publishing Infrastructure feature, you’re getting an error message on your SharePoint. That is because there are some hidden SharePoint features required to be able to
DISCLAMER: Enabling Publishing features in Modern SharePoint site will make then unsupported.
On the Reference section below is more information about the features that needed to be activated to activate successfully this feature. Some of these features are not available to be activated on the SharePoint Site Collection and because of that, we need to use PowerShell to activate those. Note this process will change your SharePoint site Structure.
The first step is to allow Custom Script on SharePoint Tenant:
- Go to your SharePoint Admin center change the URL to your tenant admin. https://contoso-admin.sharepoint.com
- If this opens the new SharePoint admin center, select Classic SharePoint admin center in the left pane.
- Select Settings.
- Under Custom Script choose:
- Allow users to run
customscript on personal sites.
- Allow users to run
customscript on self-service created sites.
- Allow users to run
- Select OK.
Note: It can take up to 24 hours for the change to take effect.
The next step is to allow Custom Script on SharePoint Site Collection and for that, we need to use the next PowerShell:
Connect-SPOService -Url https://contoso-admin.sharepoint.com Set-SPOSite -Identity https://contoso.sharepoint.com/sites/Publishing -DenyAddAndCustomizePages 0
Finally, we need to connect to the SharePoint Site Collection to activate the features that are required to have the SharePoint Server Publishing Infrastructure activated.
Connect-PnPOnline -url https://contoso.sharepoint.com/sites/Publishing Enable-PnPFeature -Identity dffaae84-60ee-413a-9600-1cf431cf0560 -force #RollupPages Enable-PnPFeature -Identity 22a9ef51-737b-4ff2-9346-694633fe4416 -force #Publishing Enable-PnPFeature -Identity f6924d36-2fa8-4f0b-b16d-06b7250180fa -force -Scope site #SharePoint Server Publishing Infrastructure of Site Collection Enable-PnPFeature -Identity 94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb -force -Scope web #SharePoint Server Publishing Infrastructure of Site
When all these processes are concluded, you’ll have the SharePoint Server Publishing Infrastructure activated on your Modern Site and start to take the advantages of these older functionalities On the article in the references section, you can find more information about those functionalities.
If you intend to revert back this process, you need to Deactivate the features in the following order:
Connect-PnPOnline -url https://contoso.sharepoint.com/sites/Publishing Disable-PnPFeature -Identity 94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb -force -Scope web #SharePoint Server Publishing Infrastructure of Site Disable-PnPFeature -Identity f6924d36-2fa8-4f0b-b16d-06b7250180fa -force -Scope site #SharePoint Server Publishing Infrastructure of Site Collection
- SharePoint Server Publishing Infrastructure details on what got unlocked – http://sharepoint.handsontek.net/2018/10/28/enable-custom-script-on-modern-sharepoint-sites-using-powershell/
- RollupPages – http://blog.vitalyzhukov.ru/en/cribs/features/16/dffaae84-60ee-413a-9600-1cf431cf0560
- Publishing – http://blog.vitalyzhukov.ru/en/cribs/features/16/22a9ef51-737b-4ff2-9346-694633fe4416
- SharePoint Server Publishing Infrastructure Site Collection – http://blog.vitalyzhukov.ru/en/cribs/features/16/94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb
- SharePoint Server Publishing Infrastructure Site – http://blog.vitalyzhukov.ru/en/cribs/features/16/f6924d36-2fa8-4f0b-b16d-06b7250180fa
Great read, do you know how to enable for Communications sites for SharePoint 2019 on prem?
The features that required to be activated are the same, but the way to activate the custom scripts are a bit different. Please review this article and follow the instruction – https://support.bindtuning.com/hc/en-us/articles/360030872511
Let me know if that worked and thanks for the comment.
Thanks a lot for this! Got the features enabled and blanked out…previously working only in SPOL for a long time, going back to onprem I’m having to grease the gears a little.
Looks like Communication Site Collections do not respond to MMS navigation the way regular publishing sites used to do. If we use these for our main intranet landing page, I’m guessing I’ll have to find a way to use CSS/Java to add global navigation that can connect either to the term store or manage global nave= strictly through CSS.
Thanks a lot for the reply and placing me on the right path with this,
Correct, the navigation will be position above the title which not looking great. I would suggest you try a BindTuning for SharePoint 2019. You’ll have the flexibility to use the MMS nav. You’ve trials for testing purposes.
Thanks and have a great day!
PowerShell is telling me The Term ‘Connect-SPOService’ is not recognized as the name of a cmdlet, function, script file or operable program. Do I need a particular version of PowerShell?
Yes, you need to install the SharePoint Online Management Shell cmdlets in order to be able to execute the PowerShell. In the below link you can find more information about that.
when i run Connect-PnPOnline -url https://xxxxxxxx
Import-Module : The specified module ‘SharePointPnPPowerShellOnline’ was not loaded because no valid module file was
found in any module directory.
At line:1 char:1
+ Import-Module SharePointPnPPowerShellOnline
+ CategoryInfo : ResourceUnavailable: (SharePointPnPPowerShellOnline:String) [Import-Module], FileNotFou
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
You’re missing the cmdlets of PnP PowerShell. Check this link where you’ve instructions on how to install it. View the title PnP PowerShell
I successfully connect to the pnp shell.
But I cant get rid of this write error running enable-pnpfeature.
PS C:\WINDOWS\System32> Enable-PnPFeature -Identity 22a9ef51-737b-4ff2-9346-694633fe4416 -force
Enable-PnPFeature : Den eksterne serveren returnerte feilen (403) Forbudt.
At line:1 char:1
+ Enable-PnPFeature -Identity 22a9ef51-737b-4ff2-9346-694633fe4416 -for …
+ CategoryInfo : WriteError: (:) [Enable-PnPFeature], WebException
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Features.EnableFeature
Solved it myself.
Connecting with -useweblogin fixed it. Used currentuser earlier.
Using mutifactor authentication on the user. Might have a connection to the solution?
Just wanted to let you all know.
Thank you for your feedback. If you have multifactor authentication on the tenant you need to add that parameter.
this is my Site “https://abcde.sharepoint.com/” and it’s in the communication site. and I used your steps to activate the publishing features. to work in classic view design. but I’m not able to find the “pages library” folder in it. i can able to find site pages. but the pages are from a modern view. which is useless for me as I want to create a design in a classic view
can you please help me to solve this.
Thanks in advance.
When these features are activated successfully, the Pages library is created. Run once more the PowerShell to make sure the features are activated.
I tried these steps in the same order to activate the SharePoint publishing infrasture feature on the communication site but they are still not activated. I didn’t see any errors in PowerShell too. How long does it take usually? Really appreciate if you could let me know if there is any way I can figure out what went wrong?
Usually activating these features takes a couple of minutes because this activates some additional features behind the scenes.
Here, Connect-PnPOnline -url https://contoso.sharepoint.com/sites/Publishing it gives me 404 FILE NOT FOUND. What can I do.
From the information that the PnP PowerShell is giving, seems that you don’t have a SharePoint site collection with that name.
I have a similar issue, I am working on the ‘Top level’ on SharePoint so I presume my line will be;
Set-SPOSite -Identity https://xxxxxxxxx.xxxxxxxxx.sharepoint.com -Deny…….
Do I remove the sites/Publishing from the address OR is required?
That will be change required on the code. If that site is a SharePoint Modern site, be aware of the potential issue that you may have.
Much appreciate this blog, I am trying to activate SharePoint publishing infrastructure, as it is online it won’t let me, but by Sharepoint Online Management Shell, it should work. I try using the code:
$siteUrl = “https://MyURL.sharepoint.com/sites/MySite”
$siteCollection = Get-SPOSite $siteUrl
Enable-SPFeature “PublishingSite” -Url $siteCollection.Url -force
Enable-SPFeature “PublishingWeb” -Url $siteCollection.Url -force
But Enable-SPFeature says it is not a command for cmdlet, I check at the list and in fact, it is not there. Do you know another way to activate it?
I would use the PnP framework to use that type of task where I need to activate any feature of SharePoint. Take a look at that here