1. My Caddy version (caddy version
):
Version 1.0.4
2. How I run Caddy:
I’m setting up a small blog. Directory structure looks like this:
/
- orange.css # my CSS
- index.html # this is where the problem is happening
- blogpost.html # a template for my blogposts
- /blog # the blogpost .md files
+ - markdowntest.md # an example .md file
a. System environment:
I’m running Arch on a VPS, Linux kernel 4.9, systemd 244.1-1.
b. Command:
cd /path/to/my/htmldir
sudo caddy
c. Service/unit/compose file:
I do not know where to look for these files, and haven’t set them up.
d. My complete Caddyfile or JSON config:
My caddyfile is:
lambda-delta.tk
markdown /blog {
css /orange.css
template blogpost.html
}
templates
3. The problem I’m having:
I am trying to generate a list of files in /blog, linked to those files, with the contents of the file afterward–basically, an index for my blog posts. However, when I try to .Include or .Markdown a file inside of the range I’m using to list all the files, I get a 500 internal server error.
Here’s the templating I’m doing in index.html:
<div class="title">Blog entries:</div>
<div class="entry">
{{.Include "blog/markdowntest.md"}} <!-- .Include and .Markdown both work here... -->
{{range $field := .Files "blog"}}
{{ $path := "blog/" }}
<a href="{{$path}}{{$field}}"></a> - {{.Include "blog/markdowntest.md"}} <!-- But using a .Include here causes a 500 Internal Server Error when I load the page. -->
{{end}}</div>
In addition, trying to do any kind of string concatenation–such as {{$path := "blog/" + $field}}
–also causes a 500 Internal Server Error.
4. Error messages and/or full log output:
Caddy starts without issues, outside of an inode complaint:
ns507181% sudo caddy
[sudo] password for dbrz:
Activating privacy features... done.
Serving HTTP on port 80
http://lambda-delta.tk
Serving HTTPS on port 443
https://lambda-delta.tk
WARNING: File descriptor limit 1024 is too low for production servers. At least 8192 is recommended. Fix with `ulimit -n 8192`.
There is no additional output after I attempt to load index.html.
Running with -log log.txt
provides the following output in log.txt:
ns507181% cat log.txt
2020/04/12 01:38:23 [INFO] Caddy version: v1.0.4
2020/04/12 01:38:23 [INFO][cache:0xc0001a2b40] Started certificate maintenance routine
2020/04/12 01:38:23 [INFO] Serving https://lambda-delta.tk
2020/04/12 01:38:23 [INFO] Serving http://lambda-delta.tk
2020/04/12 01:40:33 [INFO] SIGINT: Shutting down
2020/04/12 01:40:33 [INFO][cache:0xc0001a2b40] Stopped certificate maintenance routine
Again, nothing changes after I try to load the page. No additional output.
5. What I already tried:
I’ve narrowed it down to concatenation or running an .Include or .Markdown inside the range. I’ve gotten it working without the “preview”, and can make a list of links that go where they’re supposed to, but if I try to do anything further than that it falls apart.
6. Links to relevant resources:
Caddy V1 template actions documentation:
https://caddyserver.com/v1/docs/template-actions
Go Template docs: