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

Requirement: Change the Header Banner Image on Modern Site Pages.

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

The header banner image serves as the backdrop and creates a visual impact on Modern Pages in SharePoint Online. In this guide, let’s see the steps to change the banner image on your Modern Site Pages in SharePoint Online. Here is how to change the default header image on the ‘Site Page’ on SharePoint Online:

  1. Navigate to the modern site page. E.g., https://crescent.sharepoint.com/sites/marketing/SitePages/About-Us.aspx
  2. Click on the “Edit” button on the top right area. 
    sharepoint online add banner image
  3. 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
  4. 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.
  5. Save and publish the page.
    sharepoint online change header image

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

PnP PowerShell to Change Banner Image

Alternatively, you can also change the header background image by PowerShell. Here is the PnP PowerShell script to change the banner image on the site page:

#Parameter
$SiteURL= "https://crescent.sharepoint.com/sites/marketing/"
$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
$Page.SetCustomPageHeader($PageHeaderImage)

#Save and publish the page
$Page.Save()
$Page.Publish() 

This script Connects to SharePoint Online using the Connect-PnPOnline cmdlet, gets the page, and sets the header image.

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?

#Parameter
$SiteURL= "https://crescent.sharepoint.com/sites/marketing"
$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

    If($ClientSidePage)
    {
        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
    }
}

In summary, You can change the header background image in SharePoint Online Modern Pages by following a few simple steps through web browser UI or PowerShell, as explained above.

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!

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

  • How do I create an image for title? I have made several images but when I load them they don’t show the entire image, just a section of it that is too large to be asthetic. Is there a specific width/height or pixel x pixel or resolution that would show more of the image? I’ve expanded the image’s width and then tried height but cannot seem to reduce the image to show it smaller to display a fuller image. Not using color block option just the image and title and overlap options.

    Reply

Leave a Reply

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