I need to copy news templates from one modern site to many others, automatically. I soon realized that the template newspages is stored in Sitepages/Templates on a site.
Using PNP Copy file I can copy the template files to any site I want:
Connect-PnPOnline -Url "https://contoso.sharepoint.com/sites/DevTemplate" Copy-PnPFile -SourceUrl "Sitepages/Templates" -TargetUrl "/sites/Dev_Test21/Sitepages" -OverwriteIfAlreadyExists -Force
If I then manually creates ONE template ("ik" on pic below), the copied files also shows because they are in the Sitepages/templates already. It's like I need to create one manually to enable the template function at all.