1. The problem I’m having:
I’m trying to process some template files, saved on disk as blah.gohtml
2. Error messages and/or full log output:
The files are served by Caddy literally, so the template functionality isn’t invoked
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.
3. Caddy version:
caddy:2-alpine
4. How I installed and ran Caddy:
podman
a. System environment:
macOs something
b. Command:
podman run --rm -v ./htdocs:/usr/share/caddy -v ./Caddyfile.test:/etc/caddy/Caddyfile -p 8080:80 caddy:2-alpine
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.
c. Service/unit/compose file:
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.
d. My complete Caddy config:
:80 {
root /usr/share/caddy
#templates *.gohtml
templates {
mime_types application/octet-stream
}
encode zstd gzip
file_server
@gohtmlgohtml path *.gohtml
header @gohtml Content-Type text/html
#rewrite /articles/* /article.gohtml
rewrite /index.gohtml
route {
header *.gohtml Content-Type text/html
rewrite /articles/* /article.gohtml
rewrite /index.gohtml
file_server
templates
}
}
# i’ve tried a lot of variants here
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.
5. Links to relevant resources:
I see the content-type matching is… basic
ct := header.Get(“Content-Type”)
for _, mt := range t.MIMETypes {
if strings.Contains(ct, mt) {
return true
}
so there’s no chance of matching “text/*” or even text/plain; charset="UTF=8"
which goat do i need to sacrifice to convince Caddy to process my files as templates
![]()