How I deploy this hugo site to uberspace with git push

One of the great things about using a PaaS provider like Vercel, Netlify, etc. is that all you usually need to do, to release a new version of your site is git push and you're done. It's the default and requires no additional setup. It's extremely convenient.

This site is generated with Hugo. It's a static site generator written in Go. It is fast. Very fast.

While Vercel does have support for Hugo, I ran into some issues initially. To debug them, I would trigger a deployment, and then... wait. Not for long, though; only for like 10–15 seconds. But, given how fast Hugo spits out the build, it felt weird to wait at all. Especially when it keeps breaking but working locally.

So instead, I now do this:

const foo = "bar"
hugo && rsync -vr --delete public/ bleepbloop.studio:~/html/

And this is so much faster:

$ time pnpm run deploy
[...]
pnpm run deploy  0.26s user 0.05s system 23% cpu 1.323 total

That's 260ms! Most of that time is probably spent opening the SSH connection to my uberspace, only has to upload the changes, and as a cherry on top: it works. 1

Now, this is where some people might shake their fists angrily at cloud providers and start to talk about how web development has become infuriatingly complex, and how a decade ago everything was better. I don't, it needn't, and it wasn't. But there will be a post about that discussion soon.

I traded a lot of convenience 2 for a little more speed and wouldn't want to deploy anything that is even just slightly more complex like this.

However, for a simple statically generated site like this, it works great and is a very "low tech" kind of solution that I understand, which I like a lot. It's always a good thing, when things can be solved with basic, fundamental CLI tools.

And I gave myself a bit of extra convenience by doing this automatically on git push, but only for the main branch:

#!/bin/sh
branch=$(git rev-parse --abbrev-ref HEAD)
if [[ $branch == "main" ]]; then
pnpm run release
fi

It feels almost exactly like the original.


  1. I know why it failed on Vercel by now, and of course, it was entirely and unexpectedly my fault. 

  2. Rollbacks, ability to deploy from any machine, preview branches, edge deployment, CDN, monitoring and so much more.