Snippet / Import woes

So I’m trying to wrap my head around snippets and imports, and trying to apply it to the following:

$ tree /config
├── Caddyfile
└── domains

$ cat /config/Caddyfile
import domains/*

If I modify Caddyfile to the following:

(test) {
	root /www
import domains/*

And try to use it in domains/ like so: {
	import test

I get the following error:
“Error during parsing: File to import not found: /config/domains/test”

If I create the snippet in domains/ (where I use it), I get the same error :confused:

So what I gathered from this is that I can’t use snippets in imported files, this seems unintentional / bugged.

Hi @p3lim,

No, snippets are only usable in the main Caddyfile itself, it doesn’t cross the “import boundary”.

I believe it’s always been this way, but the docs don’t mention this limitation. If you’d like, open an issue at - either as a feature request, or to get the docs updated.

1 Like

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