This method is totally a legacy solution and should not be relied upon and it now fails when you try and save the site template file in any case with an error message:
Unable to convert the HeaderColorIndexInLightMode XML attribute for the WebTemplate XML element for feature {eb336846-9820-4ec8-a767-3b7bb5bb778e} to a positive integer value.
The proposed new approach is to use Site Designs https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/get-started-create-site-design but that is not the same as it amounts to running a series of post provisioning scripts that add lists and libraries etc. but this has its limitations (no content for example)
The ability to save a site as a proper and complete template was a staple of on-prem SharePoint for decades and Microsoft would do well to bring this capability back in a way that properly support SPO and modern sites. My bet is that they won't though - too much effort.