Sometimes it's a good idea to post links under your own domain, so that you can change the link's target when needed1.
For example, I have a Ko-Fi page at https://ko-fi.com/dtinth but I never link to that URL directly; I use http://link.dt.in.th/coffee instead. Should I ever decide to use something else2, I only need to change the link destination.
One simple, low-code way to accomplish this is use Netlify's redirect feature.
-
Create a GitHub repo and create a file
public/_redirects
:
/youtube https://www.youtube.com/channel/UClKPjyxFSkk_dPg6YzN0Miw/ 302 /coffee https://ko-fi.com/dtinth 302
Create a Netlify site linking to the GitHub repo and set up your domain.
There is no step 3.
The _redirects
file has a simple, machine-and-human-readable, plain-text format. To add or change links, just update the file on GitHub. I find this approach powerful because I can also update this file programmatically using GitHub's API, and teams can collaborate on this file like how they collaborate on code. One downside is that this approach doesn't track how many people used the link, we you'd have to track from the destination instead.
Top comments (0)