Url shortening service using a static website on Netlify
This is a quick and practical proof of concept of a “free” link redirection service, hosted on Netlify. I am using one of my domains to redirect to various URLs, to my own projects. The setup is simple and can be done in a matter of minutes.
Step 1: add your redirects in quicklinks/_redirects
. The accepted format is documented at Netlify. For more complicated cases add your rules to netlify.toml
.
For example:
Step 2: create a netlify.toml
that defines the folder quicklinks
to be deployed as live site.
Step 3: add your repository to your Netlify organisation and deploy.
Step 4: add a custom domain or make your Netlify sub-domain look nice by renaming it to something other than very-random-string.netlify.app
under “Site Configuration” > “Change site name”.
Then use your redirects.
I connected my tool-domain dnbhub.xyz
to a quick setup of URLs for my projects and you can test it by any arbitrary redirection from this setup file (I admit it’s not widely used yet). For example https://dnbhub.xyz
sends you right to my GoHugo module repository and https://dnbhub.xyz/hooks
sends you to the landing page for my hooks module.
The initial advantage of having shorter URLs is topped by your ability to change endpoints by just re-deploying a new version of your site instead of having to go through all places where you mentioned this URL. This is a great way to have a “free” URL shortening service for your own projects.
This post is part of #100DaysToOffload 50 posts since Apr 29, 2023 — 102 total posts