Friday, May 12, 2017

How to remove the banner on modern pages using Office PnP PowerShell

image

While we’re waiting for full support for modern pages and how they work in Office PnP and the SharePoint Framework, here’s how you turn off the banner on article pages – basically setting them to the layout used by the Office 365 Group Team sites.

If you want to turn the banner back on, set the PageLayoutType to “Article”.

# Connect to the site
Connect-PnPOnline https://tenant.sharepoint.com/sites/portal

# List all pages, and find the id of the modern page
Get-PnPListItem -List SitePages

# Change layout from "Article" to "Home" to remove top banner
Set-PnPListItem -List SitePages –Identity <id> -Values @{"PageLayoutType"="Home"}

image

8 comments:

  1. I am guessing that this change then makes the page hidden from the News web parts.

    ReplyDelete
    Replies
    1. It shouldn't as news picks up on a different column, not the layout.

      Delete
  2. I wish I got get this to work but i kept getting the 403 error in PowerShell. Any suggestions?

    ReplyDelete
  3. Try to edit the page in the UI, then connect with PnP and run the command.

    ReplyDelete
  4. I am guessing this is same as copying home page and creating modern pages.
    It works however it keep crushing in Here web part in SharePoint App. Is there any solution for this?

    ReplyDelete