I Created My Own URL Shortener and Ditched Bitly
troysk
June 9, 2026 ยท 2 min read
I use short links for everything, my blog posts and my GitHub repos and my booking page, because long URLs look ugly in messages and emails and are hard to share verbally. Bitly used to be free for custom domains and then they started charging and then they raised prices again, so I switched to Shlink which is a self-hosted URL shortener with analytics and tags and an API, all on my server and all free.
Shlink runs two containers, the main server and a web client interface. You set environment variables for your default domain and HTTPS settings, run docker compose up, and the web client connects to the server through an API key that you generate through the command line. The setup takes about five minutes.
Creating short URLs is straightforward through the web interface. You enter the long URL and optionally a custom short code and some tags, and Shlink generates a short URL on your domain. Custom short codes are easier to remember and share than randomly generated strings, so I use blog-post or git-repo instead of something like a three b f two.
The analytics are the feature that makes this useful beyond just link shortening. Shlink tracks total visits and unique visitors and referrers and browsers and operating systems and even geographic location. Clicking on any short URL shows its full analytics so you can see which channels drive the most traffic.
The REST API lets you create short URLs programmatically from your other tools. I use this in n8n to automatically create short URLs when I publish a new blog post, so every new article gets a clean short link without any manual work. The command-line tool works through Docker exec for scripting and automation.
Bitly is a great product but paying forty dollars a month for short links when Shlink exists and does everything Bitly does on your own server does not make sense. Set it up once and you own your links forever.
If you have thoughts on this do email me or subscribe to the newsletter for more self-hosting recommendations.
Get New Articles
Weekly guides on self-hosting, privacy, and infrastructure.
No spam. Unsubscribe anytime.