I felt the need to create my own URL Shortener. I ended up with a template repository for making URL Shorteners with Jekyll and GitHub Pages.
The source code and documentation can be found here:
URL shortening is a technique on the World Wide Web in which a Uniform Resource Locator (URL) may be made substantially shorter and still direct to the required page.
The Jekyll URL Shortener repository is a template for creating your very own URL Shortener:
✂️🔗 This is a template repository for making URL Shorteners with Jekyll and GitHub Pages. Create short URLs that can be easily shared, tweeted, or emailed to friends. Fork this repo to get started.
To create your own URL Shortener, do this:
- Buy and configure a (short) domain name
- Fork or clone the Jekyll URL Shortener repository
- Configure the repository and code to your liking
- Create short links with Jekyll pages
Here follows a description of how I created my own URL Shortener…
1. Domain Name
I bought the domain name
hlaueriksson.me from a Swedish domain name registrar.
I will use this as an apex domain, so I configured
A records with my DNS provider:
2. Fork / Clone
_config.yml file, located in the root of the repository, contains configuration for Jekyll.
I modified this file to fit my needs:
GitHub Pages of the repository provides configuration for hosting the Jekyll site.
I modified these settings to fit my needs:
4. Short Links
Short links are created as Jekyll pages in the root of the repository:
Why would you create your own URL Shortener?
Jekyll URL Shortener you could:
- Have a vanity or branded domain name
- Create neat custom slugs for the short links
- Create short links with emoji
- Track short links with Google Analytics
Jekyll URL Shortener is made possible by:
- Jekyll: https://jekyllrb.com
- jekyll-theme-minimal: https://github.com/pages-themes/minimal
- jekyll-redirect-from: https://github.com/jekyll/jekyll-redirect-from
- GitHub Pages: https://pages.github.com
The redirecting is done with the
Redirects are performed by serving an HTML file with an HTTP-REFRESH meta tag which points to your destination.
So, the HTTP status codes
301 (permanent redirect),
307 (temporary redirect) are not used.