A URL shortener using Netlify's speedy CDN-based Redirects API
This is based off Phil Hawksworth's work as detailed in the blog post
Any short URLs you add which have a corresponding .png file in the /dist/images
directory will unfurl in Twitter and other platforms to show this custom image instead of that included at the destination site.
Name images to match the short URL path thus:
/dist/images/about.png
will be used as a custom OG image when sharing https://example.com/about
You can use this repository to make your own url shortener with support for custom OG images.
- Click the Deploy to Netlify button below (which clones this repo and uses your copy to create a new site on Netlify)
- Follow the instructions to deploy your site
- Create new short URLs by adding them to the
/_redirects
directory - Optional: Gve your new site a custom domain. (Good luck coming up with a snappy sounding short domain name :) )
After cloning the repo to your local dev machine, install the dependencies by running npm i
from the project root directory.
Netlify Dev provides a local Edge Function environment and can make your local build accessible over the internet via a Netlify domain. A helper script does this for you. Run: npm start
This project uses Kent C Dodds' utility for conveniently adding rules to the _redirects
file. He has provided some helpful instructions on setting that up.
You can also use Raycast to call that command for even easier creation of new URLs. (Raycast command)