That sounds like you are just not importing the function appendix-heading() from your template.typ file?
I created a minimal working example here. The file template.typ also has the appendix() function. You can use that in place of the lines 13 to 15 in main.typ after importing it from template.typ. In that case you do not need to import appendix-heading() anymore since this is already “included” in the function appendix().