Sep 06, 2021
I found a nice domain name for shortlinks, so while the little one had a nap yesterday I hooked it up to netlify and updated my static site generator to generate a redirect file. That's two netlify configurations (one for each domain). When the original successfully builds and publishes, I've configured a success webhook to call and trigger a build of the second domain. The second domain configuration calls curl to get the redirects file from the original dominan. That's it!

Most of the code (about 25 lines) was in adding a template file for the redirects, and a little glue code to render and write the result to a file. The path is generated using the first eight characters of a hash of the blog slug (which form part of the URL and is effectively immutable).

Here's an example shortlink: