How to allow {{include "/includes/docs/head.html"}}?

1. Caddy version (caddy version):

v2.4.6

2. How I run Caddy:

http://theviewfromafar.com/index.html

a. System environment:

caddy start on Digital Ocean Ubuntu 20.4

b. Command:

caddy start

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddyfile or JSON config:

{
log {
    level DEBUG
    output stdout
    format console
}
}
theviewfromafar.com {
    redir /sbwTweet/* http://oldschool.scripting.com/sbwTweet/?{query}
    root * /var/www/tvfa
    file_server
}

3. The problem I’m having:

“includes in caddyfile” thread from a month ago suggested this solution:
{{include “/includes/docs/head.html”}}
but apparently it needs another module to work. Please suggest how to install/configure it to work.

4. Error messages and/or full log output:

The command appears in its entirety as text in the webpage.

5. What I already tried:

Looked at Modules - Caddy Documentation but it didn’t indicate how I should go forward to include the module in Caddy. Thank you.

6. Links to relevant resources:

1 Like

You’re looking for the templates handler:

If you haven’t seen it yet, we do go over templates in our documentation, right in the Caddyfile tutorial:

I highly recommend the tutorials ^_^

You’re making good progress on your sites! Congrats

Thank you for your pointer and help.

I had indented the directive with a TAB. It works when I begin the “{{include…” at the beginning of the line.

If that is a requirement, you might want to add it to the DOCs. I didn’t test it fully.

I don’t understand what you mean.

Please elaborate. What’s your full config at that point? What’s in your logs? How did you test it? What behaviour did you see exactly when it “didn’t work”?

I provided that information in my first post, including the directive returned as text.

I did change my Caddyfile to be:

theviewfromafar.com {
    redir /sbwTweet/* http://oldschool.scripting.com/sbwTweet/?{query}
    root * /var/www/tvfa
    file_server
    templates
    }

The text included in the directive was returned.

I apologize. I tried my previous configuration and can’t get it to fail. Sorry for the inconvenience. Will report if I can reproduce. Happy it works, now.

2 Likes

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