In this post we will discuss about
how to remove the Page header from the SharePoint online pages.
Typically,
most of us faced issues when we create new pages in the SharePoint online,
there will be header with the title of the page will be shown
as like below. Give the page name (Name your page section) and publish the
page. I have given the page name as TestPage.
From SharePoint
UI there is no way to hide the header at least till this article
published, so to hide the Page Header we will use PowerShell commands to hide
the content.
There are 2 ways we can achieve the hiding page header.
1) Page level - In this case we will focus only on hiding the page header for the specific page.
2) Site Level - In this approach we are disabling the Page
header at the site level.
Now we will see how we can disable for specific page.
1) Open SharePoint management shell (Run as admin)
2) Run the below scripts to disable Page header
#Declare variables sunch as Page name, Site URL
$SiteUrl = "https://bangten.sharepoint.com"
$PageTitle = "TestPage"
#UseWebLogin Uses Default Browser Authentication incase
#if we have not connected we can remove that
Connect-PnPOnline -Url $SiteUrl -UseWebLogin
#Here we are setting the Layout type to Home its kind of landing page
Set-PnPClientSidePage -Identity $PageTitle -LayoutType Home
#Later at any point of time if we want Page Header back then use the below script
#Set-PnPClientSidePage -Identity $PageTitle -LayoutType Article
Note: The above script can be run
from Windows Powershell ISE as well also I have provided script for revert it
back to old variant.
Now we will see how we can disable at site level
1) Open sharepoint management shell(Run as Admin)
2) Run the below scripts to remove the page header
#Declare variables sunch as Page name, Site URL
$SiteUrl = "https://bangten.sharepoint.com"
Connect-PnPOnline -Url $SiteUrl -UseWebLogin
$PageCollection = (Get-PnPListItem -List SitePages).FieldValues
#Here we will loop through site pages collection and set the layout
foreach($Page in $pageCollection){
Set-PnPClientSidePage -Identity $Page.FileLeafRef -LayoutType Home
#Using below line we can revert the changes
#Set-PnPClientSidePage -Identity $Page.FileLeafRef -LayoutType Article
}
From above steps we came to how we can handle Page Header
in the SharePoint Modern Pages.
No comments:
Post a Comment