As a web developer, most of my projects are online. However, my projects are hosted in several different places and it can be difficult to remember where all of them are, let alone to remember complex URLs like https://wits.github.io/regretris.
I decided to build my own URL shortener to solve these problems. After buying the domain ian.link in late 2018, I quickly set to work to build the site.
This wasn't my first URL shortener; I'd also built wits.run a few years prior. I knew that redirecting from a short link (e.g. ian.link/ex) to a longer URL (e.g. wits.github.io/example) wasn't enough to make it useful.
A good URL shortener should also make it easy for the admin to manage the shortened links. With wits.run I had to manually update the list of shortened links in a SQL database. This proved to be too tedious for me to actually use the site. So with ian.link I wanted to make it easier to get short links for new projects as soon as I created them.
I solved this problem in two ways.
First, I made sure to create a UI for myself. It allows me to enter a long URL and (optionally) the corresponding shortened link. After creating a short link, I can copy it with the click of a button. Already much better than before, but why stop there?
Second, I created a clever fallback. Because the majority of my projects are hosted on GitHub pages, they all follow a common naming scheme: https://wits.github.io/[project-name]. The [project-name] is usually a very readable, user-friendly name already, so why not use that for the short links? If ian.link doesn't find the link provided, it assumes that it's the name of one of my GitHub pages websites, and redirects the user.
By combining these two techniques, I now have an immensely more useful URL shortener than before. I can easily create new links with a few taps on my phone or by publishing my projects to GitHub pages. Not bad for one night's work.