If you’re looking for a fast, efficient, and easy way to host your Hugo website, pairing it with Caddy is a fantastic choice. Hugo is a powerful static site generator that’s loved for its speed and simplicity, while Caddy is a web server that’s known for its automated HTTPS setup and ease of use. Together, they make hosting your static site smooth and hassle-free.
In this guide, we’ll walk you through the process of hosting your Hugo website with Caddy, step by step. Whether you’re a beginner or someone with minimal technical skills, this article will simplify the process and help you get started quickly.
What is Hugo, and Why Choose Caddy?
Hugo is one of the most popular static site generators available today. It allows you to create blazing-fast websites without the need for complex databases or server-side scripting. Hugo takes your Markdown files, processes them with templates, and generates a complete website that you can easily deploy anywhere.
Caddy, on the other hand, is a modern web server that simplifies website hosting. What makes Caddy special is its automatic HTTPS support, which eliminates the need for manually configuring SSL certificates. It also has a simple and human-readable configuration file, making it beginner-friendly.
By combining Hugo’s speed and efficiency with Caddy’s simplicity and security, you can build and host a website that’s lightning-fast and easy to manage. This pairing is perfect for bloggers, small business owners, and developers who want a quick, no-fuss solution.
Install Hugo and Build Your Site
Before you can host your website with Caddy, you need to install Hugo and create your site. Here’s how you can do it step-by-step:
Step 1: Install Hugo
- Download Hugo: Visit Hugo’s official website and download the appropriate version for your operating system (Windows, macOS, or Linux).
- Install Hugo: Follow the installation instructions provided for your OS. On macOS and Linux, you can use package managers like Homebrew or apt, while Windows users can download the executable directly.
- Verify Installation: Open your terminal or command prompt and type the following command to check if Hugo is installed:bashCopyEdit
hugo version
You should see the version number of Hugo if the installation was successful.
Step 2: Create Your Hugo Site
- Run the following command to create a new Hugo site:bashCopyEdit
hugo new site my-hugo-site
Replacemy-hugo-site
with the name of your website folder. - Choose a theme for your Hugo site. Hugo has a wide selection of themes available on its official themes page. Follow the instructions to install your chosen theme.
- Start adding content to your site. Use Markdown to create new pages and posts:bashCopyEdit
hugo new posts/my-first-post.md
Step 3: Build Your Site
Run the following command to generate your static site:
bashCopyEdithugo
Hugo will generate the website files in the public/
directory. This directory contains everything you need to host your site.
Install and Set Up Caddy
Once you have your Hugo site ready, the next step is to install Caddy and configure it to serve your site.

Install and Set Up Caddy
- Download and Install Caddy:
Visit Caddy’s official website and download the latest version for your operating system. Alternatively, you can use package managers like Homebrew (macOS) or apt (Linux) for installation. - Verify Installation: Open your terminal and type the following command:bashCopyEdit
caddy version
If Caddy is installed successfully, you’ll see the version number. - Move Caddy to Your Path: If you downloaded the executable directly, ensure that you move it to a directory in your system’s PATH (e.g.,
/usr/local/bin
on Linux/macOS orC:\Windows\System32
on Windows).
Setting Up Your Caddyfile
The Caddyfile is the configuration file used by Caddy to define how your website will be served. It’s simple and easy to read. Here’s a basic example of a Caddyfile for your Hugo site:
plaintextCopyEditlocalhost
root * /path/to/your/hugo/public
file_server
- Replace
/path/to/your/hugo/public
with the path to your Hugopublic
folder. - The
file_server
directive tells Caddy to serve the static files in the specified directory.
Save this file as Caddyfile
in the root of your Hugo project directory.
Testing Caddy on Your Local Machine
Before deploying your site, test it locally to ensure everything is working. Run the following command in your terminal:
bashCopyEditcaddy run
This will start the Caddy server and serve your Hugo site locally. Open your browser and navigate to http://localhost
to see your site live.
Link Hugo with Caddy
Now that you’ve tested your Hugo site with Caddy locally, it’s time to link them together for production. Caddy’s simplicity makes this process straightforward.
- Update Your Caddyfile: For a live deployment, update the domain name in your Caddyfile to your actual domain:plaintextCopyEdit
yourdomain.com root * /path/to/your/hugo/public file_server
Replaceyourdomain.com
with your domain name. - Enable Automatic HTTPS: Caddy automatically generates and renews SSL certificates for your domain. No manual configuration is required. Just ensure that your domain points to the server where Caddy is running.
Deploy Your Hugo Site with Caddy
Hosting Locally with Caddy
For local development, running Caddy is as simple as executing the caddy run
command. However, for live deployments, you’ll likely use a VPS or cloud server.

Deploying on a VPS or Cloud Server
Here’s how to deploy your Hugo site with Caddy on a VPS or cloud server:
- Set Up Your Server: Choose a VPS provider like DigitalOcean, Linode, or AWS. Install Hugo and Caddy on the server.
- Upload Your Hugo Site: Copy the contents of your Hugo
public
directory to the server. - Run Caddy: Use the same Caddyfile you tested locally. Caddy will handle HTTPS for your live domain automatically.
Why Caddy is Perfect for Hugo Hosting
Caddy is perfect for Hugo hosting because:
- It automatically handles SSL certificates, saving you from the hassle of manual configuration.
- It’s lightweight and efficient, making it ideal for static sites.
- Its configuration is simple, even for beginners.
Troubleshooting: Common Issues and Fixes
- Site Not Loading: Check if the Caddyfile’s root path points to the correct directory.
- SSL Errors: Ensure your domain’s DNS settings are configured correctly.
- 404 Errors: Verify that your Hugo site has been built properly and that all files are present in the
public
folder.
Caddyfile Configuration Errors
Sometimes, minor typos in the Caddyfile can cause configuration errors. Always double-check for:
- Missing directives like
file_server
- Incorrect file paths
- Domain name mismatches
Use the command caddy validate
to check your Caddyfile for errors before running the server.
The Bottom Line
Hosting your Hugo website with Caddy is a simple yet powerful way to serve your static site with speed and security. Hugo allows you to build blazing-fast websites, and Caddy makes hosting them straightforward with its automatic HTTPS and user-friendly configuration. Whether you’re hosting locally or deploying to a VPS, this guide has everything you need to get started.
With the combination of Hugo and Caddy, you can focus on creating content while letting these tools handle the technical aspects of hosting. Start your journey today and experience the ease of hosting a static site with this incredible duo!