Provision sub site using PnP Site provisioning schema?

Copper Contributor

I am trying to provision a site hierarchy using the PnP site provisioning engine and an .xml file.

 

One thing I am having a bit of a problem with is how do I provision sub sites? I want to provision the following example of a site structure

 

  • Start page
  • About us (subsite, team site)
  • Resources (subsite, team site)
  • Community (Community site – site collection)
  • Documents (Document center – Site collection)

 

//Martin

10 Replies

if you are using PowerShell then after you connect to your site collection you can specify the web that you want to provision your template to.

 

Apply-SPOProvisioninTemplate -web subweburl -Path c:\temp\template.xml

 

 

Then i need to call Apply-SPOProvisioninTemplate multiple times and split this up in multiple xml files.

 

Example

Apply-SPOProvisioninTemplate -web subweburl1 -Path c:\temp\template1.xml

Apply-SPOProvisioninTemplate -web subweburl2 -Path c:\temp\template2.xml

Apply-SPOProvisioninTemplate -web subweburl3 -Path c:\temp\template3.xml

Apply-SPOProvisioninTemplate -web subweburl4 -Path c:\temp\template4.xml

 

What i would like to do is

 

Apply-SPOProvisioninTemplate -web rootsite -Path c:\temp\rootsite.xml

 

And rootsite.xml contains something like

<SubSites>

<SubSite url="subweburl1">

  //Stuff here :)

</SubSite>

<SubSite url="subweburl2">

  //Stuff here :)

</SubSite>

<SubSite url="subweburl3">

  //Stuff here :)

</SubSite>

<SubSite url="subweburl4">

  //Stuff here :)

</SubSite>

</SubSites>

Hi @Martin Segelfeldt,

 

that would be a nice idea but that's not how the PnP Provisioing engine works.

 

I created an addtional xml structure that lists out all the sites I want to deploy. Then a powerShewll script reads this xml and provisions all the sites by calling the Apply-SPOProvisioningTemplate multiple times.

PnP engine does not provision any sites. It is only able to apply templates on an existing site or extract a template from an existing site. So from your code or powershell, first provision a new sub site and then apply a template on it. This can be done using pnp.core extensions or using plain csom/rest api's. Within the PnP schema there is a sequence element available in order to define a site structure (site collections and sites). Only the PnP engine does not do anything (yet) with the sequences.

I did all try using the sub site structure migration using your mentioned commands for our project. Its only migrate the Site collection level structure not sub site level structure. 

 

What I observe is subsite level structure migration shows things to be done in PowerShell log trace but actually nothing get created in the targeted subsite.

 

 

Not deploy or not working subsite to subsite migration of the Site structure. 

I have tried all the way for migrating sub site CT from one tenant to another tenant. CT which are created at subsite levels and columns which are taken in the CT which are from the site collection levels not getting exported even. Import is failed too. 

 

We have migrated SC level all CT and site structure and then migrated sub site level structure where CT, Site columns are missing from the exported xml file. 

Hi @nitinkumar kakulde,

 

That is expected behaviour.To get the content types and fields you will bneed to export the root site within your site collection and then apply that to the rootsite of the site collection where you want these contenttypes to appear.

Hi @Pieter Veenstra

 

There is a flag to allow for ContentTypes to be provisioned to sub webs (-ProvisionContentTypesToSubWebs). Is that feature depreciated?

That would not deploy the content types to a subsite if the contentypes in the template are site collection content types. I would expect that contenttypes that are exported at a certain scope ( site collection, web, list) to keep their scope.