ParseFiles function error

It is giving me the error of :
template/login.html: no such file or directory

But that directory exists

func startLoginHtml(w http.ResponseWriter, r *http.Request) {
    log.Println("Merging Html Files")
    var homepage QuestData
    layout := path.Join("template", "login.html")
    content := path.Join("template", "content.html")

    tmpl, err := template.ParseFiles(layout, content)
    if err != nil {
	    log.Println("Error", err)
    tmpl.ExecuteTemplate(w, "my-template", homepage)
    log.Println("Finished Merging Html")

Hey @Panda_Verified, my first guess would be that either the login.html file doesn’t exist, or that you are running your code from a folder that isn’t the folder that the login.html file exist’s within.

Lastly, you should also check the error from ExecuteTemplate as well because that may end up causing you problems separately.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.