Using hugo with coolify/nixpacks doesn’t just “work” depending on your git setup. There are two approaches that can be taken with getting things to play nice assuming you already have your site’s repo connected to coolify for deployment. Option #1 being to define a custom nixpacks.toml, and option #2 being to version control your static files, and forgo building on the server.

Option #1:#

As of September 18th, 2024 a new site made with hugo version 0.112.3 works on coolify version v4.0.0-beta.341 with the following modifications

Using the following nixpacks.toml config along with enabling static site and setting publish directory to /public will allow coolify the build your site automatically using the github app integration (cicd).

[phases.setup]
aptPkgs = ["hugo"]

[ phases.build ]
cmds = ["hugo --minify"]

[ environment ]
HUGO_VERSION = "0.112.3"

[[ nixpacks.included_files ]]
paths = ["/public"]

Then you will additionally add a Staticfile (ref) to the root of your repo, so that the nixpacks detect command will be able to determine the type of nixpacks setup to use.

Also this setup assumes that hugo’s config file is named config.toml and is located at the root of your repo. If you are using a custom config file location, you will need to add a –config flag to the hugo build command in the nixpacks.toml file.

Option #2:#

Going with the regular static route, you would either remove the public/ line from your .gitignore file so that you can build locally, ensuring your baseURL is correct in your hugo.toml, then build after any changes are made and push the resulting public directory. Or alternatively you can use a github action integration like https://github.com/marketplace/actions/build-hugo to build your project upon commit. Then the rest is just like setting up any other static site in coolify.