Minimal URL shortener that can be entirely hosted on GitHub pages. Wednesday, Nov 18, 2020
GitHUB SOURCE : https://github.com/nelsontky/gh-pages-url-shortener/
GitHub Pages URL Shortener
This is a minimal URL shortener that can be entirely hosted on GitHub pages. It does not need the maintenance of any servers or databases and can be hosted entirely on GitHub for free.
nlsn.cf/1 should link to this repo.
To add a new short link, add an issue with the title being the link you want to shorten (including the
http(s)://) to https://github.com/nelsontky/gh-pages-url-shortener-db/issues.
The newly created short url can be accessed via
Unlike many URL shorteners, this one
does not need a databaseuses a “database” in the form of GitHub issues and can be entirely hosted on GitHub pages.
There is no need for the pound symbol - short URLs look clean like this:
nlsn.cf/1instead of looking like this:
How does this work?
Thanks to @kidGodzilla for the pretty neat explanation here.
- CNAME points URL to
- 404.html handles all requests
This is so cool! How can I use this with my own domain?!
Disclaimer: This method of creating a URL shortener is hacky and not meant to be reliable or used in production. Do proceed at your own risk!
- Fork the repo before cloning your fork.
- Set up GitHub pages for your forked repo.
- In your forked repo, click the Settings tab and scroll down to the GitHub Pages section.
- Then select the main branch source and click on the Save button.
- If you are using your own domain:
- Set your domain up for GitHub pages.
- Change the URL in
CNAMEfile to your domain.
- If you are using GitHub page’s default domain i.e. Something like
- Delete the
var PATH_SEGMENTS_TO_SKIP = 0;at the top of
var PATH_SEGMENTS_TO_SKIP = 1;.
- This is as GitHub domains have an additional path segment (the repo name) after the host name.
- Delete the
- Create a new repo as a database. (Or you could use your forked repo)
var GITHUB_ISSUES_LINK = "<your-github-issues-link>";at the top of
- Format for
- Remember the trailing
- Format for
- Push your changes to your forked repo, and your low cost and cool as heck URL shortener will be ready for use!
To feature your fork here, edit this section and open a PR!
Article Title: Minimal URL shortener that can be entirely hosted on GitHub pages.
This article URL：Minimal URL shortener that can be entirely hosted on GitHub pages.
Github Trending Repositories
Explore Github Trending Repositories. See what the GitHub community is most excited about today.