Using a Document Library to store global Document Templates

With the use of Content Types, you can assigned a Document Template to the content type. That way when the user goes to create a new document of that content type, they will be given a Word/PowerPoint/Excel document that you want them to use. For example a company expense form, or a company report document.

Typically you would create a content type, and upload the document template you wish to use. Then you add the content type to your library and then every time you wish to create a new document the document template opens. However if you look under the covers although you have just uploaded one document template, the document template is being copied into each Document library the content type is being added to.

With the use of SharePoint Designer I can prove this point.

I have created a Content Type called CandC Document, and added a few extra site columns to it.

Then in the advance settings I have uploaded a Document Template that I wish my Content Type to use.

By opening my site in SharePoint Designer, click on All files, and in the _cts folder, there is now a folder named after my Content Type. (This is the first copy of my Document Template within SharePoint)

After creating a document library called Team Documents and adding my Content Type I can then use my document template.

However if I look at this document library in SharePoint Designer, I see that SharePoint has actually copied my Document Template to be local to the list. (This is the second copy of my Document Template within SharePoint)

Every document library I create and add the document template to will also create a copy. (This is the X copy of my Document Template within SharePoint).

Now you are right if you are thinking, when I have a new Document Template I just need to go to the Content Type, upload the new template and ensure that when I click OK, ensuring I’ve selected Yes for ‘Update all content types inheriting from this type’. This works fine in one site collection, therefore having multiple copies isn’t really an issue.

What if the Content Type being used in multiple site collections?

If the Content Type is being used in multiple site collections and you wish to update the Document template then the choices are to:

  1. Use the Content Hub.
  2. Define a document library in a different site collection as the global location.

Manually going to each site collection and update the Content Type.

This is a valid option, you might only have 4 site collections. Hopefully you have used code to create your content types in each site collection (otherwise the GUID’s) won’t match. If you have 100s of site collections this isn’t suitable. You will still have multiple copies of your Document Template.

Use the Content Type Hub.

The full explanation and setup of the Content Type hub is out of scope for this document, but basically it is a built in publishing of content type mechanism. You would create the Content Type in the Content Hub with the Document Template and then publish the content type. This will be pushed out to every site collection. Any updates/changes to the Content Type (including changing the Document Template) can be republished and pushed out to all site collections. Again this a valid option, however there can be caveats using the Content Type Hub, and I fully recommend you do your research online before making this decision. Not all site columns play nicely with the Content Hub. Also using this approach you are creating copies of your Document Template everywhere.

Define a document library in a Site Collection as the Global Location.

This is the solution I’ve used recently and it ensures there is just one copy of the Document Template. The update is instantly, unlike using the Content Hub which relies on a timer job to push the changes everywhere, and there isn’t multiple copies of the template. Also you have the added bonus that because you are storing the Document Template is a Document Library, you can apply versioning, workflow approval on it too if you wish.

You will need to ensure your Content Types are created in code, as you need the GUID’s to match.

First create a document library in the Site Collection you are going to store your document templates in. Then upload all your document templates into this library. Please note, that if you wish to use your document template with multiple content types then you will need to have a copy for each content type still. (I know I said one copy, but there are limitations if using the same document template for multiple content types and you will understand why later, also having one document template for each content type even if they are the same is not a bad idea, as in the future the documents templates could different from each other.)

So I have create my Site Collection on my root site (can be any other site collection), and created my Document Library called Document Template. Inside my document library I have create 2 folders, one called CandC and once called Cann0nF0dder. Inside each folder is the same two templates I want to assign to my Content Types. Ensure you have also given everyone access to this library.

In your other site collections, using code, however you wish to do it, PowerShell, C# CSOM or JavaScript, create your Content Types in your Sites and ensure that the Document template URL is a relative path to your Document template stored in the global location. Below is sample PowerShell code I used for this demo.

$UserName = Read-Host -Prompt "UserName"
$Password = Read-Host -Prompt "Password" -AsSecureString
$Url =

#location is
$location = "/DocumentTemplates"
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"

$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $Password)

#Create Content Type
$lci = New-Object Microsoft.SharePoint.Client.ContentTypeCreationInformation
$lci.Description = "CandC Document"
$lci.Name = "CandC Documents"
$lci.ID = "0x0101005F05888B19FD40C798741D9F1B5401E4"
$lci.Group = "CandC"

#Add Content Type
$contentType = $ctx.Web.ContentTypes.Add($lci)

#Update Document Template
$contentType.DocumentTemplate = $location + "/CandC/CCDocument Template.docx"

#Create Content Type
$lci = New-Object Microsoft.SharePoint.Client.ContentTypeCreationInformation
$lci.Description = "CandC Presentation"
$lci.Name = "CandC Presentation"
$lci.ID = "0x0101005F05888B19FD40C798741D9F1B5401E5"
$lci.Group = "CandC"

#Add Content Type
$contentType = $ctx.Web.ContentTypes.Add($lci)

#Update Document Template
$contentType.DocumentTemplate = $location + "/CandC/CCPresentation Template.pptx"

The above code only creates 2 content types (CandC Document and CandC Presentation), and it also doesn’t add the additional columns I wanted, you’ll have to work that out on your own for now. However I did create 4 content types, one for each document template.

By going into the Content Type, and viewing the Advanced Settings, you will see that it is pointing to the correct location in my Global Document Template library.

I’ve added these content types to my library (this can also be done in code) and now select whatever content type/template I wish to use.

However we are not finished yet. I discovered that when I select a Content Type, it opens up the relevant template, but when I save it back to the list, the Content Type for the document is the default content type for the library (in my case Document) not the Content Type I have picked. Also, any extra columns in my Content type were not showing up in the Document Information Panel at the top of the Microsoft Office application.

To ensure that it saves with the correct content type, you need to use your code to deploy the content types to the site collection that is holding the Global Templates. Then you need to add these Content Types to the document library that is holding the Document Templates.

Edit the property of each document and assign them to the correct content type.

Now when you create a new document from one of the content types, first of all you will notice that the Document Information panel displays with your columns.

After you have saved your document back to your library, you will also notice that it has been saved with the correct content type.

By using SharePoint designer I can also check that there is no template stored within the Site Collections, the only location you will find your template is in the Site Collection holding your Global Document Templates.