FWIW, here’s a better way to do Markdown in v2.
Usually, plain Markdown files are not meant to be served directly, even when rendered. In other words, you wouldn’t usually render file.md
and serve its resulting HTML, because there would be no proper <!DOCTYPE>...<head>...<body>
structure, and there would also be no styling or behavior!
So, I think serving Markdown directly like what you’re trying to do is not very common, because it is not very useful.
Most sites (including the Caddy site!) will serve a regular .html
file as a template file, which has this action somewhere in its body:
{{markdown "..."}}
to embed the Markdown file within a proper HTML document with styling and behavior. HTML files get a proper Content-Type without needing to modify the system MIME store, so it just works, and is a lot easier and more useful than rendering Markdown directly.
If you still want to render and serve Markdown files with .md
extensions directly, either:
- rename them to use
.txt
(a recognized plaintext extension), - or add a MIME association for
.md
to your system, - or using something like
header index.md Content-Type text/markdown
in your Caddyfile.