g1y is a short URL manager built with Eleventy (a.k.a. 11ty), the great JavaScript/Node based Static Site Generator.
This is not a URL "shortener", as it doesn't process anything. Short and long versions of URLs are managed manually, so that short URLs can be "beautiful".
Also included are /notes
(like blog posts), /messages
with background images, and /holidays
like /messages
but for holidays and special occasions
g1y generates redirection rules from your set of data, each URL being stored in a Markdown file:
- the
fileSlug
of the Markdown file (the filename without the extension in 11ty language) is the short URL. For example, the Markdown filepluto.md
you'll find in this template repository is used to create the https://<your-short-domain>/pluto short URL. - the long URL is stored in the file's Front Matter, for example here the
pluto.md
file only contains these 3 lines:--- url: https://en.wikipedia.org/wiki/Pluto ---
So for this example, when you go to https://<your-short-domain>/pluto, it redirects you to https://en.wikipedia.org/wiki/Pluto.
Redirection rules are generated in 4 formats to ease usage on different environments:
- Apache HTTP server with Alias module in a
.htaccess
file - Apache HTTP server with Rewrite module (less efficient) in the same
.htaccess
file - Netlify hosting with redirects in a
_redirects
file - HTML pages with both HTML redirect (
<meta>
tag) and JavaScript Redirect. This is only meant as a last resort, only there if previous formats don't work. Your HTTP server needs to be able to respond to https://<your-short-domain>/pluto with this actual resource: https://<your-short-domain>/pluto/index.html - Vercel also works -- not sure which one of the formats it's using.
You don't have to deal with any settings to chose which one to use, all 4 formats are generated at once.
Using the github.com or gitea self-hosted git repository, the README.md can also serve as the blog.
A script (bin/ar-multi-readme.sh
) is included to add any notes using the relative url shortcut eg, your-post
which points to a note eg, /notes/2021-01-20-your-post.md
and prepends the note(s) to README.md, which makes the github or gitea repo url a (poor man's) blog, with links to each of the included posts in the repo.
# prepend your-post, another-post, yet-another-post notes
# to README.md and blog.md files which reside in repo root
# (although could be /another_dir/blog.md)
bin/ar-multi-readme.sh your-post,another-post,yet-another-post README.md,blog.md
Eventually will need a way to trim / cull the README.md
Modified from https://github.com/nhoizey/1y
Kudos to 1y
Copyright (c) 2021-present