My own URL shortener without a URL shortening service

Jul 22, 2026

Whenever I needed to share a long link, I used to rely on public URL shorteners. But at some point I started wondering - why, if I already own hleb.dev domain? It’s short enough, and I could always self-host an open-source URL shortener (or even write my own). As it turned out, I didn’t need a separate service at all.

Post cover

My blog is built with Hugo and deployed to Cloudflare Pages via GitHub Actions. Cloudflare Pages supports an _redirects file that lets you configure HTTP redirects.

The format is very straightforward. For example, we can add the following line:

/wiki-bot https://github.com/hleb-kastseika/daily-wiki-pic 301

And after the next deployment, hleb.dev/wiki-bot redirects to github.com/hleb-kastseika/daily-wiki-pic. That’s it.

No database, no backend, and no separate service. The entire list of short links is just a plain text file in my Git repository. I really like that the infrastructure I already use to publish my blog turns out to be a perfect fit for this use case as well.

Now all of my short links are under my control, versioned by with the blog repository, and automatically deployed through my CI/CD pipeline.