SharePoint onprem and SharePoint online updates never been same.Most of required feature which are available in SPOnline is not available in SharePoint On-prem. One of them is template based page creation.As of today you can create page with provided template in communication site but not available in Team site. So here is the small solution, by using we can provide plenty of predefined template to end users for their easiness.
Lets start:
Step 1: Create a empty page, just add your columns and widgets into into , like I have created. Refer below screenshot.
So here I have added few widget and created a blank page page, once you page created just save that page.
Step 2: After saving the page just run below script to get the Canvas content of the page.
$templatePageName= "demo-page.aspx" $oWeb = Get-SPWeb "<Site URL>" $pageLibrary = $oWeb.Lists["Site Pages"] $page = $pageLibrary.GetItems() | select Name, ID | where { $_.Name -eq $templatePageName } if ($null -ne $page.ID) { $canvasContent = $pageLibrary.GetItemByID($page.ID)["CanvasContent1"] $canvasContent | Out-File -FilePath C:\canvasContent.txt } else { Write-Host "Page Id not found" -ForegroundColor DarkCyan }
Step 3: After running above script you will find the Canvas content text in text file with name “canvasContent.txt” which is generated in C drive of your machine.Now copy that text and pass it to “CanvasContent1” property.
Step 4: Refer article Create Modern page using C# in SharePoint’19 on-prem and pass text of canvasContent.txt file to “CanvasContent1” property.
That’s it, like this you can provide functionality to create page with your own template.