Let users create modern site pages

Let users create modern site pages

Using SharePoint Online pages is a great way to share ideas using images, Excel, Word and PowerPoint documents, video, and more. Users can create and publish modern pages quickly and easily, and they look great on any device.

If you're a global or SharePoint admin in Office 365, you can allow or prevent the creation of SharePoint Online site pages by users. You can do this organization-wide by changing settings in the SharePoint admin center, or at the site level by using a Microsoft PowerShell script.

Note: The following procedures are for SharePoint pages only. When you allow creation of site pages, the Add a page command in the Settings menu creates new site pages. If you turn off the ability to create site pages, users can still add a SharePoint page from the New menu on the Home page and add from the classic page to a Wiki library using the same command.

Allow or prevent creation of site pages at the organization level in the SharePoint admin center

  1. Sign in to Office 365 as a global admin or SharePoint admin.

  2. Select the app launcher icon The icon that looks like a waffle and represents a button click that will reveal multiple application tiles for selection. in the upper-left and choose Admin to open the Office 365 admin center. (If you don't see the Admin tile, you don't have Office 365 administrator permissions in your organization.)

  3. In the left pane, choose Admin centers > SharePoint.

  4. In the left pane, choose settings.

  5. Next to Site pages, select either Allow users to create site pages or Prevent users from creating site pages.

  1. Download the latest SharePoint Online Management Shell.

  2. Install the SharePoint Online Client Components SDK.

  3. Connect to SharePoint Online as a global admin or SharePoint admin in Office 365. To learn how, see Getting started with SharePoint Online Management Shell.

    Note: Read About Execution Policies and make sure you run the SharePoint Online Management Shell as an administrator and the correct execution policy to run unsigned scripts.

  4. Copy the following code and paste it into a text editor, such as Notepad.

    # Load SharePoint Online Client Components SDK Module
    Import-Module 'C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll'
    
    # Set script constants
    $sitePagesFeatureIdString = 'B6917CB1-93A0-4B97-A84D-7CF49975D4EC'
    
    # Set up client context
    $userName = Read-Host "Username"
    $password = Read-Host "Password" -AsSecureString
    $siteUrl = Read-Host "Site Url"
    $webUrl = Read-Host "Server-Relative Web Url"
    $context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
    $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $password)
    $context.Credentials = $credentials
    
    # Get the list of existing features
    $web = $context.Site.OpenWeb($webUrl)
    $features = $web.Features
    $context.Load($features)
    $context.ExecuteQuery()
    
    # Verify that the Site Pages feature is present in the web
    if(($features | ? { $_.DefinitionId -eq $sitePagesFeatureIdString }).Count -eq 0)
    {
    	Write-Host "The Site Pages feature is already disabled in this web"
    	return
    }
    
    # Remove the Site Pages feature from the web
    $features.Remove((new-object 'System.Guid' $sitePagesFeatureIdString), $false)
    $context.ExecuteQuery()
    
    # Verify that the Site Pages feature is no longer present in the Web
    $web = $context.Site.OpenWeb($webUrl)
    $features = $web.Features
    $context.Load($features)
    $context.ExecuteQuery()
    if(($features | ? { $_.DefinitionId -eq $sitePagesFeatureIdString }).Count -eq 0)
    {
    	Write-Host "The Site Pages feature has been successfully disabled"
    }
    else
    {	
    	throw "The Site Pages feature failed to be disabled"
    }
    
  5. Save the text file, and then change its extension. In this example, we name it SitePagesOut.ps1.

    Note: You can use a different file name, but you must save the file as an ANSI-encoded text file whose extension is .ps1.

  6. Change to the directory where you saved the file.

  7. Run the following command:

    ./SitePagesOut.ps1
  8. The script will prompt you for a SiteUrl and WebUrl.

    If you have a site such as "https://contoso.sharepoint.com/sites/marketing/northwindcompete"

    For the SiteUrl you would enter: https://contoso.sharepoint.com/sites/marketing

    And for the WebUrl you would enter sites/marketing/northwindcompete

  1. Download the latest SharePoint Online Management Shell.

  2. Install the SharePoint Online Client Components SDK.

  3. Connect to SharePoint Online as a global admin or SharePoint admin in Office 365. To learn how, see Getting started with SharePoint Online Management Shell.

    Note: Read About Execution Policies and make sure you run the SharePoint Online Management Shell as an administrator and the correct execution policy to run unsigned scripts.

  4. Copy the following code and paste it into a text editor, such as Notepad.

    # Load SharePoint Online Client Components SDK Module
    Import-Module 'C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll'
    
    # Set script constants
    $sitePagesFeatureIdString = 'B6917CB1-93A0-4B97-A84D-7CF49975D4EC'
    
    # Set up client context
    $userName = Read-Host "Username"
    $password = Read-Host "Password" -AsSecureString
    $siteUrl = Read-Host "Site Url"
    $webUrl = Read-Host "Server-Relative Web Url"
    $context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
    $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $password)
    $context.Credentials = $credentials
    
    # Get the list of existing features
    $web = $context.Site.OpenWeb($webUrl)
    $features = $web.Features
    $context.Load($features)
    $context.ExecuteQuery()
    
    # Verify that the Site Pages feature is not present in the web
    if(($features | ? { $_.DefinitionId -eq $sitePagesFeatureIdString }).Count -gt 0)
    {
    	Write-Host "The Site Pages feature is already enabled in this web"
    	return
    }
    
    # Add the Site Pages feature back to the web
    $features.Add((new-object 'System.Guid' $sitePagesFeatureIdString), $false, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None)
    $context.ExecuteQuery()
    
    # Verify that the Site Pages feature is now present in the web
    $web = $context.Site.OpenWeb($webUrl)
    $features = $web.Features
    $context.Load($features)
    $context.ExecuteQuery()
    
    if(($features | ? { $_.DefinitionId -eq $sitePagesFeatureIdString }).Count -gt 0)
    {
    	Write-Host "The Site Pages feature has been successfully enabled"
    }
    else
    {
    	throw "The Site Pages feature failed to be enabled"
    }
    
  5. Save the text file, and then change its extension. In this example, we name it SitePagesIn.ps1.

    Note: You can use a different file name, but you must save the file as an ANSI-encoded text file whose extension is .ps1.

  6. Change to the directory where you saved the file.

  7. Run the following command:

    ./SitePagesIn.ps1
  8. The script will prompt you for a SiteUrl and WebUrl.

    If you have a site such as "https://contoso.sharepoint.com/sites/marketing/northwindcompete"

    For the SiteUrl you would enter: https://contoso.sharepoint.com/sites/marketing

    And for the WebUrl you would enter sites/marketing/northwindcompete

Expand your Office skills
Explore training
Get new features first
Join Office Insiders

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.

×