Personal Link Shortener
Published Mon Dec 23 2024I recently acquired a domain name to use for redirects. This was inspired by Cassidy William’s cass.run site that does the same thing.
Since this site is already deployed on Netlify, it was easy to add my new domain (drake.codes) to my Netlify account. From there I deployed a new Git repo that contains my redirects. There’s 2 ways you can configure this for Netlify:
Using _redirects
The _redirects
file can be added to the root of your site and Netlify will apply these redirects. I have used this in the past when I changed the route of my posts from /post/:id
to /posts/:id
. I know, a small change that really doens’t matter but I wanted to do it and Netlify made it easy!
/post/* /posts/:splat 301!
Using netlify.toml
Another place you can configure site redirects is the netlify.toml
. These can be added using TOML’s inline table syntax:
[[redirects]]
from = "/dots"
to = "https://github.com/bottd/dotfiles"
status = 200
[[redirects]]
from = "/*"
to = "https://www.drake.dev/"
status = 200
I started with netlify.toml
, but ultimately landed on using _redirects
for brevity. For now my only redirect is from drake.codes/dots to my dotfiles GitHub repo. I’m sure I’ll think of some more useful links for myself later. Until then this is a pretty nifty tool I now have for little effort. Thanks Netlify!