Hide the template gallery from newly created sites in SharePoint

When you create new team or communication sites in SharePoint, the first user that visits will be presented with a template gallery picker:

This is a great feature for simpler solutions or where you utilize the Site Design to apply your solution. For organizations using their own provisioning solution the site might already be ready to use for the end-user and this dialog might cause confusion, and even end up in the user breaking your ready made site with their own template.

Disable the template dialog with PowerShell

Using the PnP.PowerShell module (https://pnp.github.io/powershell/) you could in example run this after applying a provisioning template:

Connect-PnPOnline Url https://contoso.sharepoint.com/sites/project101
$Web = Get-PnPWeb Includes WebTemplatesGalleryFirstRunEnabled
$Web.WebTemplatesGalleryFirstRunEnabled = $false
$Web.Update()
Invoke-PnPQuery

Disable the template dialog with C#

If you are using the PnP.Framework for C# (https://github.com/pnp/pnpframework) you could add this code to your solution to disable the dialog:

public async Task DisableTemplateGalleryDialog(SharePointClientContext context)
{
Web web = context.Web;
context.Load(web);
await context.ExecuteQueryRetryAsync();
web.WebTemplatesGalleryFirstRunEnabled = false;
web.Update();
await context.ExecuteQueryRetryAsync();
}

Summary

The web template dialog adds a great capability for basic usage, or even when using Site Design, but can cause unnecessary confusion where you have a enterprise grade provisioning solution. In these cases it can make sense to disable the dialog.

One thought on “Hide the template gallery from newly created sites in SharePoint

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 )

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