That pages are different in publishing site and a team site is quite clear. A less known difference between publishing sites and team sites are the document libraries. You might have noticed the difference in the Url Documents and Shared Documents, but that doesn’t matter much. It’s just a library!

In one of my current projects I have a publishing portal with a sub site that contains an end user solution. This  solution needs to be moved to it’s own site collection. I don’t need to worry about the data so I just need to get the site structure across. So I’m planning to use the PnP PowerShell options that I’m familiar with.

The elements

The element that need to be copied are:

  • site columns and content types from the root site collection (this is a publishing portal)
  • The solution specific lists (this is a team site)

The dilemma

When I create the new site collection as a team site then I’m going to struggle with all the publishing parts that come across from the original site collection.

When I create a publishing based site collection then the import of the lists and pages are going to be a struggle.

My Initial thought: Never create a mixture of team sites and publishing sites!

The Problem

When I apply a template to a site of the ‘wrong type’. Then I’m getting errors complaining about the DocumentTemplates

So what does Apply-PnPProvisioningTemplate : Invalid template URL mean?

I’m applying a template based on a team site to a publishing site using:

Apply-PnPProvisioningTemplate -Web pubtest -Path c:\temp\teamdoc.xml -Handlers Lists

Working towards the solution

So I exported my two document libraries with Get-PnPProvisioningTemplate

When exported from a publishing site:

 <pnp:ListInstance Title=”Documents” Description=”This system library was created by the Publishing feature to store documents that are used on pages in this site.” DocumentTemplate=”{site}/Documents/Forms/template.dotx” TemplateType=”101″ Url=”Documents” EnableVersioning=”true” MinorVersionLimit=”0″ MaxVersionLimit=”500″ DraftVersionVisibility=”0″ TemplateFeatureID=”00bfea71-e717-4e80-aa17-d0c71b360101″ EnableAttachments=”false”>
<pnp:ContentTypeBindings>
<pnp:ContentTypeBinding ContentTypeID=”0x0101″ Default=”true” />
<pnp:ContentTypeBinding ContentTypeID=”0x0120″ />
</pnp:ContentTypeBindings>
<pnp:Views>
<View Name=”{1753AA73-A21A-4B2E-B8D0-C2EFD4FB8921}” DefaultView=”TRUE” MobileView=”TRUE” MobileDefaultView=”TRUE” Type=”HTML” DisplayName=”All Documents” Url=”/pubtest/Documents/Forms/AllItems.aspx” Level=”1″ BaseViewID=”1″ ContentTypeID=”0x” ImageUrl=”/_layouts/15/images/dlicon.png?rev=44″>
<Query>
<OrderBy>
<FieldRef Name=”FileLeafRef” />
</OrderBy>
</Query>
<ViewFields>
<FieldRef Name=”DocIcon” />
<FieldRef Name=”LinkFilename” />
<FieldRef Name=”Modified” />
<FieldRef Name=”Editor” />
<FieldRef Name=”CheckoutUser” />
</ViewFields>
<RowLimit Paged=”TRUE”>30</RowLimit>
<JSLink>clienttemplates.js</JSLink>
</View>
</pnp:Views>
<pnp:FieldRefs>
<pnp:FieldRef ID=”ae3e2a36-125d-45d3-9051-744b513536a6″ Name=”_dlc_DocId” DisplayName=”Document ID Value” />
<pnp:FieldRef ID=”3b63724f-3418-461f-868b-7706f69b029c” Name=”_dlc_DocIdUrl” DisplayName=”Document ID” />
<pnp:FieldRef ID=”ccc1037f-f65e-434a-868e-8c98af31fe29″ Name=”_ComplianceFlags” DisplayName=”Label setting” />
<pnp:FieldRef ID=”d4b6480a-4bed-4094-9a52-30181ea38f1d” Name=”_ComplianceTag” DisplayName=”Labels” />
<pnp:FieldRef ID=”92be610e-ddbb-49f4-b3b1-5c2bc768df8f” Name=”_ComplianceTagWrittenTime” DisplayName=”Label Applied” />
<pnp:FieldRef ID=”418d7676-2d6f-42cf-a16a-e43d2971252a” Name=”_ComplianceTagUserId” DisplayName=”Label applied by” />
<pnp:FieldRef ID=”8382d247-72a9-44b1-9794-7b177edc89f3″ Name=”_IsRecord” DisplayName=”Item is a Record” />
</pnp:FieldRefs>
</pnp:ListInstance>

 

When exported from a team site:

<pnp:ListInstance Title=”Documents” Description=”” DocumentTemplate=”{site}/Shared Documents/Forms/template.dotx” OnQuickLaunch=”true” TemplateType=”101″ Url=”Shared Documents” EnableVersioning=”true” MinorVersionLimit=”0″ MaxVersionLimit=”500″ DraftVersionVisibility=”0″ TemplateFeatureID=”00bfea71-e717-4e80-aa17-d0c71b360101″ EnableAttachments=”false”>
<pnp:ContentTypeBindings>
<pnp:ContentTypeBinding ContentTypeID=”0x0101″ Default=”true” />
<pnp:ContentTypeBinding ContentTypeID=”0x0120″ />
</pnp:ContentTypeBindings>
<pnp:Views>
<View Name=”{C2A6BF61-01A3-4C6F-9801-A578DD8D5688}” DefaultView=”TRUE” MobileView=”TRUE” MobileDefaultView=”TRUE” Type=”HTML” DisplayName=”All Documents” Url=”/teamtest/Shared Documents/Forms/AllItems.aspx” Level=”1″ BaseViewID=”1″ ContentTypeID=”0x” ImageUrl=”/_layouts/15/images/dlicon.png?rev=44″>
<Query>
<OrderBy>
<FieldRef Name=”FileLeafRef” />
</OrderBy>
</Query>
<ViewFields>
<FieldRef Name=”DocIcon” />
<FieldRef Name=”LinkFilename” />
<FieldRef Name=”Modified” />
<FieldRef Name=”Editor” />
</ViewFields>
<RowLimit Paged=”TRUE”>30</RowLimit>
<JSLink>clienttemplates.js</JSLink>
</View>
</pnp:Views>
<pnp:FieldRefs>
<pnp:FieldRef ID=”ae3e2a36-125d-45d3-9051-744b513536a6″ Name=”_dlc_DocId” DisplayName=”Document ID Value” />
<pnp:FieldRef ID=”3b63724f-3418-461f-868b-7706f69b029c” Name=”_dlc_DocIdUrl” DisplayName=”Document ID” />
<pnp:FieldRef ID=”ccc1037f-f65e-434a-868e-8c98af31fe29″ Name=”_ComplianceFlags” DisplayName=”Label setting” />
<pnp:FieldRef ID=”d4b6480a-4bed-4094-9a52-30181ea38f1d” Name=”_ComplianceTag” DisplayName=”Labels” />
<pnp:FieldRef ID=”92be610e-ddbb-49f4-b3b1-5c2bc768df8f” Name=”_ComplianceTagWrittenTime” DisplayName=”Label Applied” />
<pnp:FieldRef ID=”418d7676-2d6f-42cf-a16a-e43d2971252a” Name=”_ComplianceTagUserId” DisplayName=”Label applied by” />
<pnp:FieldRef ID=”8382d247-72a9-44b1-9794-7b177edc89f3″ Name=”_IsRecord” DisplayName=”Item is a Record” />
</pnp:FieldRefs>
</pnp:ListInstance>

 

Time to take a closer look at that:

<pnp:ListInstance Title=”Documents” Description=”” DocumentTemplate=”{site}/Shared Documents/Forms/template.dotx” OnQuickLaunch=”true” TemplateType=”101″ Url=”Shared Documents” EnableVersioning=”true” MinorVersionLimit=”0″ MaxVersionLimit=”500″ DraftVersionVisibility=”0″ TemplateFeatureID=”00bfea71-e717-4e80-aa17-d0c71b360101″ EnableAttachments=”false”>

 

<pnp:ListInstance Title=”Documents” Description=”This system library was created by the Publishing feature to store documents that are used on pages in this site.” DocumentTemplate=”{site}/Documents/Forms/template.dotx” TemplateType=”101″ Url=”Documents” EnableVersioning=”true” MinorVersionLimit=”0″ MaxVersionLimit=”500″ DraftVersionVisibility=”0″ TemplateFeatureID=”00bfea71-e717-4e80-aa17-d0c71b360101″ EnableAttachments=”false”>

 

Before applying the template based on a team site to a publishing site, I changed Shared Documents to Documents. 

Then I reapply the template and my error message has disappeared.

Afterthoughts

Quite a lot of people activate publishing features on team sites. This isn’t a good idea. Document Libraries and Page Libraries  will be doubled up/mixed up. making it difficult to create reliable templates. The better approach would be to get templates from a source site and then remove the page libraries and document libraries from template before applying it.

Advertisements