Modifying Modern Site Header Layout with Code

SharePoint modern site header layout customization options were introduced to Targeted Release Office 365 tenants in the beginning of 2019. With these options you can customized header layout, background and change the site logo.

Header customization options.

There are two layout options available: Standard and Compact.

Standard header
Compact header

Site logo allows uploading of a new logo and removing a logo. If you want to reuse your logo from another site you need to update logo URL via code or you can set logo URL via classic site settings, which you can access by going to “Site information”, clicking “View all site settings” and opening “Title, description and logo” from “Look and feel” -section, or just by adding /_layouts/15/prjsetng.aspx after you site url.

For header background, there are four options from left to right: None, Neutral, Soft and Strong.

Header background options

Modifying header with PnP PowerShell

Header layout options can be easily modified with just few lines of PnP PowerShell.

Connect-PnPOnline <site url>
$web = Get-PnPWeb -Includes HeaderEmphasis,HeaderLayout,SiteLogoUrl
$web.HeaderLayout = "Compact" #Options: Standard, Compact
$web.HeaderEmphasis = "Strong" #Options None,Neutral,Soft,Strong
$web.SiteLogoUrl = <Url to your logo>

$web.Update()
Invoke-PnPQuery

2 thoughts on “Modifying Modern Site Header Layout with Code

Add yours

Leave a Reply to Vinod Dangudubiyyapu Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: