Requirement: Save a page as a template in SharePoint Online.
How to Save a Modern Page as a Template in SharePoint Online?
Page Templates in SharePoint Online provide great re-usability and save a lot of time. Once you finish customizing a page by adding web parts, content, styles, etc., you can save it as a template and create new pages from it so that you don’t have to start from scratch again! To save any modern page as a template in SharePoint Online, follow these steps:
- Navigate to the page that you would like to save as a template.
- Edit the page and choose the “Save as template” menu item from the save drop-down menu.
- This saves the page as a template under the “Templates” folder of the site pages library. At a later point in time, You can edit this page template if needed. Updating the page layout won’t affect any pages that are already created from the template.
Alternatively, you can navigate to any page, click on “Promote” from the toolbar and choose “Save as Page Template” to create a new page template. You can also use: New >> “Copy of this page” from the drop-down menu of any page to create a new page from an existing one.
And now, anyone can create new pages from the template! If you choose a page template, a new modern page will be created exactly with the template page’s same structure and look & feel.
You can click on the tiny three vertical dots to set it as a default template or remove the template from the site!
Once you create a page from the template, you can further customize the created page by adding/removing web parts and other content (That won’t affect your saved template, BTW!).
PnP PowerShell to Create Modern Page Template
To save a modern page as a template in SharePoint Online using PowerShell, you can use the following script:
$SiteURL = "https://crescent.sharepoint.com/sites/Retail"
$PageName = "Team-Documents.aspx" #"About-us.aspx"
# Connect to PnP Online
Connect-PnPOnline –Url $SiteURL -Interactive
# Get the Page
$Page = Get-PnPClientSidePage –Identity $PageName
# Save page as template
This script connects to your SharePoint Online site, gets the modern page with the specified URL, and saves it as a template with the specified name.