404 from Go Template

0. The situation exist in the caddy doc website.

As I can not send URL (new member) I put it in code, sorry.

See : https://github.com/caddyserver/website/blob/master/src/docs/index.html

So I describe the caddy doc website error instead of mine because all source is public.

1. I want to serve a status 404 from a template:

I replicate the code from the caddy website project, but instead serving a 404 pages, an empty 200 page is send.

The code located here
https://github.com/caddyserver/website/blob/master/src/docs/index.html do not create a 404 error (see https://caddyserver.com/docs/test)

There is a missing part to handle this code :

{{if not (fileExists $markdownFilePath)}}{{httpError 404}}{{end}}

2. No error message, the page is just a blank page with status 200.

3. Caddy version: Latest

4. How I installed and ran Caddy:

This is the official doc website.

a. System environment:


b. Command:

No relevant

d. My complete Caddy config:

see https://github.com/caddyserver/website/blob/master/Caddyfile

5. Links to relevant resources:

Project : GitHub - caddyserver/website: The Caddy website
File with httpError 404 : {{$title}} — Caddy Documentation
Sample (empty 200 instead of 404) : https://caddyserver.com/docs/test

Just to be clear, are you running the website on your own computer with Caddy and you’re looking for help, or is this Site Feedback (and the wrong category was chosen)?

Both assertions are true.
I m not sure if the caddy documentation need a 404 status as I need it.
We can move this in the Site Feedback as the answer will kill my pain point too.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.