Here is the structure of my project.
.
├── go.mod
├── go.sum
├── internal
│ ├── buildinfo
│ │ └── buildinfo.go
│ ├── cli
│ │ └── cli.go
│ ├── db
│ │ ├── db.go
│ │ └── migrations.go
│ ├── handlers
│ │ ├── handler.go
│ │ └── routes.go
│ └── models
│ └── models.go
├── main.go
├── Makefile
├── tailwind.css
└── templates
└── base.html
The "frontend" is made of HTML templates rendered by Go's html/template. I already provide the tailwind.css script at /tailwind so
no need to include their cdn link.
Each template has the following structure
{{define "template_name"}}
html content
{{end}}When we need to compose templates we have a "parent" template that takes child templates. Looks like this
{{define "base"}}
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{.Title}}</title>
</head>
<body>
{{.Content}}
</body>
</html>
{{end}}The child template is parsed and turned into a string then injected into the parent. I only use that for sites where we have a clear base and all the pages can share the same