Invoke-PnPSiteTemplate Error: no such file or folder

After installing the new version of the SharePoint Patterns and Practices (PnP) PowerShell module and trying to invoke (apply) a site template using the Invoke-PnPSiteTemplate the following error occurred:

This turned out a issue with the template XML file with the footer links within the template XML file. When the footer links are internal and reference pages within the template the XML references a relative URL from the template instead of a fully qualified URL. The easiest way to fix this is remove the whole <pnp:Footer> section from the XML site template and add the links separately using another PnP cmdlet:

Add-PnPNavigationNode -Location Footer -Title “The title” -Url “<fully qualified URL”

Or use some PowerShell to replace the URLs in the Footer XML elements before applying the template to the new site:

#Read in the Site Template
$template=Read-PnPSiteTemplate “<path to the template XML file>”

#Replace the links (replace <tenant> with your tenant url)
$template.Footer.FooterLinks|ForEach-Object {$_.Url = $_.Url -replace “/sites/IntranetDepartmentTemplate”,”https://<tenant>{site}”

#Invoke and apply the template
Invoke-PnPSiteTemplate -InputInstance $template

About the author