SharePoint Online: How to Change Home Page using PowerShell?
Requirement: Set Home Page in SharePoint Online.
How to Change the Default Home page in SharePoint Online?
The welcome page or Home page is the default page displayed when you browse to a site. By default Home.aspx page in the Site Pages library is defined as the site welcome page. You can create a new page and set it as the site's welcome page. To set the home page in SharePoint Online:
SharePoint Online: Set Modern Page as Homepage
How to make a page as homepage in SharePoint Online? In modern sites, You can change the site home page by navigating to:
SharePoint Online: Change home page using PowerShell
Here is the PowerShell to set the page as a homepage in SharePoint Online.
PnP PowerShell to Make Document Library as home page in SharePoint Online
This time lets set a document library as home page for a SharePoint Online site using PnP PowerShell
How to Change the Default Home page in SharePoint Online?
The welcome page or Home page is the default page displayed when you browse to a site. By default Home.aspx page in the Site Pages library is defined as the site welcome page. You can create a new page and set it as the site's welcome page. To set the home page in SharePoint Online:
- Navigate to Site Settings >> Click on "Welcome Page" link under "Look and Feel" group
- This takes you to the "Site Welcome Page" (/_layouts/15/AreaWelcomePage.aspx) where you can pick any existing page and set it as a welcome page or home page for your SharePoint Online site.
To get "Welcome page" link in site settings, "SharePoint Server Publishing" feature must be activated. Once it is active, you'll get Welcome Page link in the Site Settings.
SharePoint Online: Set Modern Page as Homepage
How to make a page as homepage in SharePoint Online? In modern sites, You can change the site home page by navigating to:
- Click on "Site Settings" gear >> Site Contents
- Click on "Site Pages" Library >> Right-click on the target Home page, and select "Make Home Page" from the context menu.
SharePoint Online: Change home page using PowerShell
Here is the PowerShell to set the page as a homepage in SharePoint Online.
#Load SharePoint CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" #Set Parameter Values $SiteURL="https://crescent.sharepoint.com" #Relative url of the homepage $HomePageURL="SitePages/default.aspx" #Setup Credentials to connect $Cred = Get-Credential $Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password) #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Ctx.Credentials = $Cred #sharepoint online powershell set home page $Ctx.web.RootFolder.WelcomePage = $HomePageURL $Ctx.web.RootFolder.Update() $Ctx.ExecuteQuery()This PowerShell CSOM script sets the home page in SharePoint Online.
PnP PowerShell to Make Document Library as home page in SharePoint Online
This time lets set a document library as home page for a SharePoint Online site using PnP PowerShell
#Config Variables $SiteURL = "https://crescenttech.sharepoint.com/Sales" #Page Relative URL to the Web $HomePageURL = "Shared Documents/Forms/AllItems.aspx" #Get Credentials to connect $Cred = Get-Credential #Connect to PNP Online Connect-PnPOnline -Url $SiteURL -Credentials $Cred #Set Home page Set-PnPHomePage -RootFolderRelativeUrl $HomePageURLSimilarly, You can set a List page as Home page by setting the $HomePageURL parameter to: $HomePageURL = "Lists/PortfolioTracker/AllItems.aspx"
Set-PnPHomePage -RootFolderRelativeUrl Shared%20Documents/Forms/AllItems.aspx
No comments:
Please Login and comment to get your questions answered!