title: Golang to create a main layout webpage
body: <p>I'm new to Golang and am trying to start a web server using Go. I already wrote the html, css and js for the basic layout but am having trouble displaying the website after starting the server.</p>
  
  <p>Using this page as a guide <a href="http://sanatgersappa.blogspot.com/2013/11/creating-master-page-for-your-go-web-app.html" rel="nofollow noreferrer">link</a>. Just using my own written html, CSS and JS files as visual layout.</p>
  
  <p>What happens is the header, footer, etc combines just fine but it is displayed as text in the browser, with tags and all. I'm not sure why it is not being displayed properly. I am not sure if it could be because I'm not rendering as html using templates.HTML but I cannot find much information on this. Thank you all in advance! Go code as below: <a href="https://github.com/jzng89/TLDR-GO" rel="nofollow noreferrer">Github link</a></p>
  
  <pre><code> package main
  
  import (
      "fmt"
      "html/template"
      "log"
      "net/http"
      "os"
      "path/filepath"
      "strings"
  )
  
  type Page struct {
      Title string
  }
  
  //-------------------------------------------------------------------------------------//
  //Compile templates on start
  var templ = func() *template.Template {
      t := template.New("")
      err := filepath.Walk("./", func(path string, info os.FileInfo, err error) error {
          if strings.Contains(path, ".html") {
              fmt.Println(path)
              _, err = t.ParseFiles(path)
              if err != nil {
                  fmt.Println(err)
              }
          }
          return err
      })
  
      if err != nil {
          panic(err)
      }
      return t
  }()
  
  //---------------------------------------Page Handlers----------------------------------//
  //Handler for homepage
  func homepageHandler(w http.ResponseWriter, r *http.Request) {
      fmt.Println("Home")
      err := templ.ExecuteTemplate(w, "index", &amp;Page{Title: "Welcome to TL;DR"})
      if err != nil {
          http.Error(w, err.Error(), http.StatusInternalServerError)
      }
  }
  
  //Handler for about page
  func aboutHandler(w http.ResponseWriter, r *http.Request) {
      fmt.Println("About")
      err := templ.ExecuteTemplate(w, "about", &amp;Page{Title: "About TL;DR"})
      if err != nil {
          http.Error(w, err.Error(), http.StatusInternalServerError)
      }
  }
  
  //Handler for test Page
  func testHandler(w http.ResponseWriter, r *http.Request) {
      if r.Method == "GET" {
          fmt.Println("Test")
          testT, _ := template.ParseFiles("static/test.html")
          testT.Execute(w, nil)
      }
  }
  
  func main() {
      //--------------------------------------Routers-------------------------------------//
      http.HandleFunc("/", homepageHandler)
      http.HandleFunc("/about", aboutHandler)
      http.HandleFunc("/test", testHandler)
  
      http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
      //---------------------------------------------------------------------------------//
  
      //log to file
      f, err := os.OpenFile("serverlog.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
      if err != nil {
          log.Fatalf("Error opening file: %v", err)
      }
      defer f.Close()
      logger := log.New(f, "Logged : ", log.LstdFlags)
      log.SetOutput(f)
  
      //start server
      logger.Println("Starting server on port 9090")
      logger.Fatal(http.ListenAndServe(":9090", nil))
  
  }
  </code></pre>
  
  <p><strong>Edit:</strong> Updated 20181214</p>
  
  <p><a href="https://i.stack.imgur.com/Pa63e.png" rel="nofollow noreferrer">File Directory</a></p>
  
  <p><a href="https://i.stack.imgur.com/UXt9T.png" rel="nofollow noreferrer">Snapshot of webpage after code update</a></p>
  
  <p>My html code is basically the same format as the website but I do have some javascript and local css files which are part of my html (only for simple transition, no jquery). Could this affect the parsing? Go version <code>go version go1.10.1 windows/amd64</code></p>
  
  <p><strong>Solved:</strong> Updated 20181215</p>
  
  <p>Thanks @A.R pointing out the issue with my html header having extra characters!</p>