This page is about Caddy 1 and will go away soon because Caddy 2 is now available. Click here for Caddy 2.

User Guide

import

import allows you to use configuration from another file or a reusable snippet. It gets replaced with the contents of that file or snippet.

This is a unique directive in that import can appear outside of a server block. In other words, it can appear at the top of a Caddyfile where an address would normally be. Like other directives, however, it cannot be used inside of other directives.

Note that the the import path is relative to the Caddyfile, not the current working directory.

Syntax

import pattern

Examples

Import a shared configuration:

import config/common.conf

Imports any files found in the vhosts folder:

import ../vhosts/*

Import a snippet defined earlier:

import mysnippet

Need help with this feature?

Join us in the Caddy forum, where the open source community gathers to share their knowledge.

Does your company use Caddy?

Purchase a commercial license to use Caddy with your business and for basic email support, along with other benefits!