Creating site Templates in sharepoint online

Audi86 756 Reputation points
2022-07-29T22:18:29.163+00:00

Hi,

I am in desperate need the way to create a template out of existing SharePoint site.
I have tested https://learn.microsoft.com/en-us/powershell/module/sharepoint-online/get-spositescriptfromweb?view=sharepoint-ps
The issue is this is not replicating the webpart structure so this metho is only copying schema but i want true copy like web part as well. Is there any way?
Thanks

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,922 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 36,501 Reputation points Microsoft Vendor
    2022-08-01T02:31:12.123+00:00

    Hi @Audi86 ,
    Per my research, we are unable to copy page with web part as a template. There is no such function in powershell currently. As a workaround we can get sharepoint web part alone by Get-PnPWebPartXml.

    Get-PnPWebPartXml -ServerRelativePageUrl "/sites/demo/sitepages/home.aspx" -Identity a2875399-d6ff-43a0-96da-be6ae5875f82  
    

    Here is more details in the document
    https://pnp.github.io/powershell/cmdlets/Get-PnPWebPartXml.html


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    1 person found this answer helpful.

  2. Audi86 756 Reputation points
    2022-08-08T21:03:19.883+00:00

    Just to update for those who are looking for solution.

    I was able to perform complete site template using PnP powershell module and json config file.
    For PnP Template info : https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/introducing-the-pnp-provisioning-engine

    For Config file : https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/configuring-the-pnp-provisioning-engine

    Only thing is list items dont move using this method but that you can also achieve it using PnP ListsToExtract switch to create list.xml template and adding items in template using Add-PnPDataRowsToSiteTemplate and apply list template to the site created from template earlier.

    thanks


  3. Cinzia Tarantola 1 Reputation point
    2022-11-24T15:32:22.77+00:00

    Hi Audi86, can you give me some more info about the steps needed to make the template visible in "Apply a site template > From Your Organization", I'm trying to create a template for Subsites, I can aply the template via powershell but I don't understand how to make it visible in the Organization Template Gallery.

    The code I'm using from powershell is:

    $SiteURL = "https://xxx.sharepoint.com/sites/root/originalsite/"
    $jsonConfig = "C:\SubSite\subsite-company-config.json"
    $SchmaXMLPath = "C:\SubSite\SiteSchema.xml"
    Connect-PnPOnline -Url $siteUrl -Interactive
    Get-PnPSiteTemplate -Configuration $jsonConfig -Out "$SchmaXMLPath"

    $SiteURL = "https://xxx.sharepoint.com/sites/root/destinationsite/"
    $SchmaXMLPath = "C:\SubSite\SiteSchema.xml"
    Connect-PnPOnline -Url $SiteURL -Interactive
    Invoke-PnPSiteTemplate -Path $SchmaXMLPath

    Thanks


  4. Cinzia Tarantola 1 Reputation point
    2022-11-25T08:05:47.063+00:00

    Hi Audi86,
    I was able to create a Site Template with Json and powershell, without site pages and contents but still better than nothing :)
    Thanks

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.