diff --git a/Makefile b/Makefile index 4b181ba..15e070c 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,9 @@ build: @echo "Copying templates and static..." mkdir -p $(BUILD_DIR)/templates mkdir -p $(BUILD_DIR)/static + mkdir -p $(BUILD_DIR)/pages cp -r templates/* $(BUILD_DIR)/templates/ + cp -r pages/* $(BUILD_DIR)/pages/ cp -r static/* $(BUILD_DIR)/static/ clean: rm -rf $(BUILD_DIR) diff --git a/main.go b/main.go index 473d5b5..edf085b 100644 --- a/main.go +++ b/main.go @@ -13,12 +13,13 @@ func pageHandler(w http.ResponseWriter, r *http.Request) { path = "/home" } - tmpl, err := template.ParseFiles( - filepath.Join("templates/layout.html"), - filepath.Join("templates/header.html"), - filepath.Join("templates/footer.html"), - filepath.Join("pages/"+path+".html"), - ) + tmpl, err := template.Must(template.ParseGlob("templates/*.html")).Clone() + if err != nil { + http.NotFound(w, r) + return + } + + _, err = tmpl.ParseFiles(filepath.Join("pages", path+".html")) if err != nil { http.NotFound(w, r) return