SharePoint Online: How to Change the Home Page using PowerShell?

Requirement: Set the 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 the site. By default, the Home.aspx page in the Site Pages library is defined as the site’s welcome page. You can create a new page and set it as a welcome page. To set up the home page in SharePoint Online, do the following:

  1. Navigate to Site Settings >> Click on the “Welcome Page” link under the “Look and Feel” group.
    SharePoint Online Set Home Page
  2. 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.
    sharepoint online powershell set home page

This changes the welcome page in SharePoint Online.

The “Welcome page” link in site settings is available only in publishing site or sites with SharePoint Server Publishing feature activated.

SharePoint Online: Set Modern Page as Homepage

How to make a custom page as a homepage in SharePoint Online? On modern sites, You can change the site’s home page by navigating to:

  1. Click on “Site Settings” gear icon >> Choose “Site Contents”.
  2. 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 to modern sites

This sets the page as the home page in SharePoint Online! The same procedure applies to the modern team site or communication site collections.

SharePoint Online: Change the 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
#Relative url of the homepage

#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

This PowerShell CSOM script sets the home page in SharePoint Online.

Make Document Library the home page in SharePoint Online

How to make a document library as the homepage in SharePoint Online? You can create a new page, add the document library web part to it, pick the relevant document library, and then set that page as the home page by going to Site contents >> Site Pages >> Select the Page and click on “Make homepage” from the toolbar.

How about setting a document library as the start page on “Classic Experience”? Sure, follow these steps:

  1. Navigate to the document library >> Click the Settings gear >> > Edit page.
  2. Click on the Page tab in the ribbon from the top of the page and select “Make Homepage”, and confirm the to make document library a homepage in sharepoint online
  3. Click on “Stop Editing” to commit your changes.

Now, you should see that the document library is the site’s homepage. You can also create a new wiki page and use the above method.

You can also set SharePoint home page using SharePoint Designer!

PnP PowerShell to Make Document Library as home page in SharePoint Online

This time, let’s set a document library as a home page for a SharePoint Online site using the PnP PowerShell cmdlet Set-PnPHomePage.

#Config Variables
$SiteURL = ""
#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

#make a document library as home page in sharepoint online
Set-PnPHomePage -RootFolderRelativeUrl $HomePageURL 

Similarly, You can set a List page as a Home page by setting the $HomePageURL parameter to: $HomePageURL = “Lists/PortfolioTracker/AllItems.aspx”.

Set-PnPHomePage -RootFolderRelativeUrl Shared%20Documents/Forms/AllItems.aspx

How to Recreate a Home Page in SharePoint Online?

The existing home page is deleted, and you get a “404 Error” in SharePoint Online. If it can’t be restored from the recycle bin, Here is how to create a new home page on a SharePoint site:

  1. Navigate to the “Site Contents” page with the URL shortcut: /_layouts/15/viewlsts.aspx (e.g.,
  2. Click on “Site Pages” in the Site Contents
  3. Create a new site page by clicking on “New” >> “Site Page”.
  4. Enter the name of your modern SharePoint page, add the necessary content to it, and then publish.
  5. Once published, Right-click on the newly created page and select “Make homepage”.

If you want to set up the Home site for your SharePoint Online tenant, refer: How to Set the Home Site in SharePoint Online?

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. Passionate about sharing the deep technical knowledge and experience to help others, through the real-world articles!

3 thoughts on “SharePoint Online: How to Change the Home Page using PowerShell?

  • Hi Salaudeen, thanks for sharing, There is a way to do this in SharePoint 2016?

    Kind regards

  • I need to do this to several site collections. I migrated the sites from a SharePoint 2007 farm and all the homepages defaulted to one that does not exist. Ideally I’d like it to read a CSV for the site collection variable. The homepage should be home.aspx.


Leave a Reply

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