Forum Discussion

Martin Segelfeldt's avatar
Martin Segelfeldt
Copper Contributor
Sep 29, 2016

Provision sub site using PnP Site provisioning schema?

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

  • 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.
  • 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

     

     

    • nitinkumar kakulde's avatar
      nitinkumar kakulde
      Copper Contributor

      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.

       

       

    • Martin Segelfeldt's avatar
      Martin Segelfeldt
      Copper Contributor

      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>

      • nitinkumar kakulde's avatar
        nitinkumar kakulde
        Copper Contributor

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

Resources