Lesson 20 of 60
GoTemplate Rendering with `html/template`
15 minutes
Course progress33%
HTML Templates
This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.
html/template auto‑escapes content, preventing XSS.
tmpl := template.Must(template.ParseFiles("index.html"))
type PageData struct { Title string; Items []string }
{
data := PageData{Title: , Items: []{, , }}
tmpl.Execute(w, data)
}