Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Suri | 328 | 5 months ago | 2 | mit | JavaScript | |||||
Your own link shortener that's easily deployed as a static site (for free) | ||||||||||
Urlzap | 39 | 2 years ago | 1 | mit | Go | |||||
⚡️ Your own static URL shortener | ||||||||||
S | 3 | 3 years ago | n,ull | gpl-3.0 | HTML | |||||
Minimal URL shortener that can be entirely hosted on GitHub pages. | ||||||||||
Custom Url Shortener | 1 | a year ago | mit | CSS | ||||||
A Jekyll & Javascript based URL shortener for personal use |
Your own static URL shortener
Static site generators, published on Github Pages, are quite popular nowadays. But what about a static URL shortener (to not say generator), which allows you to redirect URLs based on static files?
Usually, developers end-up setting up a server with redirects for this (not statically). That is where URLZap comes in. It generates URLs using files and HTML wizardry, allowing users to host their own URL redirects into Github Pages.
Example project: brunoluiz/_
You might be asking yourself: how is this done without a server? Well, the answer lies on
<meta http-equiv="refresh" />
. It works as HTTP 301 (Redirect) status code, but it is done
in the client-side. There is a bit more explanation on w3c website.
Based on a config.yml
containing the desired path and URL, urlzap
will create index.html
files which make use of meta refresh tags. It is not perfect as a HTTP 301, but is quite close.
A similar strategy is used by other static website generators, such as Hugo.
An example would be:
path: './links' # default is './'
urls:
google: https://google.com
tools:
github: https://github.com
Each key in the map will map to {.path param}/{key}
routes, redirecting to {value}
.
This would generate the following:
- links/
- google/
- index.html (contains redirect)
- tools/
- github/
- index.html (contains redirect)
These files can be uploaded to Github Pages for example, not requiring any server. On
brunoluiz/_
you can see an example config.yml
and checkout
the output in gh-pages
branch
Check the releases section for more information details
Use brew
to install it
brew tap brunoluiz/tap
brew install urlzap
Using the previous YAML example:
path: './links' # default is './'
urls:
google: https://google.com
tools:
github: https://github.com
urls
: desired URL map, following the {key}:{redirect URL}
patternpath
: output pathTo generate the static files, run urlzap generate
.
Most likely you will end-up using Github Pages together with this tool. If so, perhaps the best
way to use it and reap its benefits is through Github Actions. Head to
brunoluiz/urlzap-github-action
for more details
on how to install it, covering generation & deployment.
You might need to manually enable Github Pages in your repository! More details at Github Pages guide
If Github Actions are not for you, try the following manual process instead.
config.yml
main
gh-pages
) and run git reset --hard origin/main
(this will reset the HEAD to master
)urlzap generate
The following script follows what is described on the steps above:
#!/bin/bash
# adds, commit and push your changes
git add config.yml
git commit -m 'chore: update config.yml'
git push -u origin main
# make gh-pages branch to be the same as main
git checkout gh-pages
git reset --hard origin/main
# generate files
urlzap generate
# add, commit and push generated files
git add --all
git commit -m 'chore: update HTML files'
git push -u origin gh-pages --force