Register Templates folder to support custom page templates

Office 365 provides nice and fast experience to create new pages. It allows the end user to pick template, based on which the page is going to be created. The structure, content type and assigned metadata are going to be copied from the base page. By default, SP offers three predefined templates:

  • Blank
  • Visual
  • Basic text

This is already something, but not really useful for content editors. Naturally, every company will have its own templates with custom pictures, structure and default metadata. To cope with that scenario, SharePoint allows to create own templates based on the existing page. So far so good but the real problem is that the template is available only on the single site collection. What it it needs to be used over several sites? Doing it manually doesn’t make any sense.

PnP Templates for the rescue

The easiest way to handle the task would be to create PnP provisioning template that contains the required pages and apply it to all the sites where the templates need to be available. The problem is that after doing that, the pages are still not visible in the panel.

Register folder to be used as templates source

To complete the task, there is still one thing to do. We need to tell SharePoint to use the folder where the pages are created, as a templates source. By default, SharePoint creates and registers ‘Templates’ folder when the first template is created from UI.

Below, you can find the script that creates ‘Templates’ folder and sets it as a templates folder. To do it, ‘vti_TemplatesFolderGuid’ with UniqueId of the selected folder property needs to be assigned to root folder of Site Pages library:

$templatesFolder = Resolve-PnPFolder -SiteRelativePath "SitePages/Templates"
Set-PnPPropertyBagValue -Folder "SitePages" -Key "vti_TemplatesFolderGuid" -Value $templatesFolder.UniqueId

Thanks to that, your custom templates will be automatically visible in the page creation pane.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s