Trying Hugo on Vercel
I’m a big fan of Vercel’s deployment model, but I don’t do frontend work, so I’ve never really had a reason to play with it. Enter Hugo, which Vercel also supports, and which I’ve been planning to try for a tech blog.
Getting Started⌗
Vercel makes it very easy to bootstrap a Hugo project. You can create a new repo based on a sample Hugo project directly from the admin UI. The new site is deployed immediately, using a default Hugo CD flow.
Setting up a custom domain was also easy. The recommended configuration was to use a www.luckymike.dev
as the canonical domain, and to redirect luckymike.dev
, which is the opposite of what I’d expect. This was easy enough to update, but it was a little surprising.
Updating the Site⌗
Things got bumpier when I tried to change the theme. At first, I tried to add a new theme as a Hugo module. This is very easy to do locally, but failed during the Vercel build step, because their build systems don’t have go installed. It’s possible to install go, but customizing the install
and build
commands to install a theme defeats a lot of the benefits that Vercel offers.
I switched to using a git submodule
, and then encountered errors due to the Vercel Hugo version being too old:
WARN 2023/07/01 19:38:25 Module "terminal" is not compatible with this Hugo version; run "hugo mod graph" for more information.
Vercel provides a dropdown menu to choose your node version, but doesn’t expose the Hugo version in the UI. I added hugo version
to the build step, to find out which version was installed, and it was 0.58.2, which is surprisingly old. I made several failed attempts to update the install command, before finding a discussion thread that showed how to usevercel.json
to set the Hugo version. Once I did that, things worked.
Overall Impression⌗
It took about an hour of trial and error to get things working (which included some theme browsing). Overall, that’s pretty quick, but it was longer than I expected. In contrast, a React site just worked, on the first try. Hugo is not covered in the current vercel.json docs, so my usage might be off-label. Now that I have the builds working, I expect they’ll continue to work without issue. My use case is pretty simple, though, and I’m not sure what sort of issues the lack of Hugo Module support might present. All-in-all, I’m satisfied. I love the deployment experience, and the free Vercel plan does what I need.