We can save the modern site (modern team site and communication site) as the site template by visiting
When you access
/_layouts/savetmpl.aspx , access denied may occur. It occurs because the
denyaddandcustomizepages of this site is
true. DenyAddAndCustomizePages determines whether the Add And Customize Pages right is denied on the site collection. By default, the right is denied on the modern site collection.
We need to connect to SharePoint Online using PowerShell and set
denyaddandcustomizepages of the site to
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."
Connect-SPOService -Url https://<tenant>-admin.sharepoint.com -Credential $userCredential
set-sposite https://<tenant>.sharepoint.com/sites/<communication/team> -denyaddandcustomizepages $false
Ten, you can access
/_layouts/savetmpl.aspx page and save the site as template.