SharePoint Online: How to Change the Header Banner Image in Modern Site Pages?

Requirement: Change the Header Banner Image in Modern Site Pages

How to Change the Header Background image in SharePoint Online Site Page?

Here is how to change the default header image on the ‘Site Page’ on SharePoint Online:

  • Navigate to the modern site page. E.g.
  • Click on the “Edit” button on the top right area. 
    sharepoint online add banner image
  • Click on the top-header area to select it and then click on the little image icon as shown below.
    sharepoint online header background image
  • You can upload a new image, use a URL, or select an existing image for a banner from the site. Once selected, drag and set a focal point.
  • Save and publish the page.
    sharepoint online change header image

SharePoint Banner Size: Here is the SharePoint Online modern page banner image size recommendations from Microsoft: Banner Image Size Reference for SharePoint Online

PnP PowerShell to Change Banner Image:

Here is the PnP PowerShell script to change the banner image on the site page:

$SiteURL= ""
$PageName = "About-us.aspx"
$PageHeaderImage = "/sites/marketing/images/banner.png"  #Server Relative URL

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Get Client Side Page
$Page = Get-PnPClientSidePage -Identity $PageName

#Set page header image

#Save and publish the page

Add Banner Image to All Pages in Site Pages Library

What if you want to change the banner image for all pages in the “Site Pages” library?

$SiteURL= ""
$LibraryName = "Site Pages"
$PageHeaderImage = "/sites/marketing/SiteCollectionImages/banner.png"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Get all Pages from the Library
$Pages = Get-PnPListItem -List $LibraryName

#Loop through each Page 
ForEach($Page in $Pages)
    #Get the Modern Site Page - Errors on Classic Pages
    $ClientSidePage = Get-PnPClientSidePage -Identity $Page.FieldValues.FileLeafRef -ErrorAction SilentlyContinue

        Set-PnPPage -Identity $ClientSidePage -HeaderType Custom -ServerRelativeImageUrl $PageHeaderImage -Publish  #-TranslateX 5.2 -TranslateY 10.5
        Write-host -f Green "Changed Banner in Page:"$Page.FieldValues.FileRef

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

One thought on “SharePoint Online: How to Change the Header Banner Image in Modern Site Pages?

Leave a Reply

Your email address will not be published. Required fields are marked *