{{define "content"}} {{- if not (eq .HTMX.Request.Target "posts")}} {{template "top-content" .}} {{- end}} {{template "posts" .}} {{- if not (eq .HTMX.Request.Target "posts")}} {{template "file-msg" .}} {{- end}} {{end}} {{define "top-content"}}

Hello{{if .IsAuth}}, {{.AuthUser.Name}}{{end}}

{{if .IsAuth}}Welcome back!{{else}}Please login in to your account.{{end}}

Recent posts

Below is an example of both paging and AJAX fetching using HTMX

{{end}} {{define "posts"}}
{{- range .Data}}

Gopher

{{.Title}}
{{.Body}}

{{- end}}
{{- if not $.Pager.IsBeginning}}

{{- end}} {{- if not $.Pager.IsEnd}}

{{- end}}
{{end}} {{define "file-msg"}}

Serving files

In the example posts above, check how the file URL contains a cache-buster query parameter which changes only when the app is restarted. Static files also contain cache-control headers which are configured via middleware. You can also use AlpineJS to dismiss this message.
{{end}}