Minimal custom urls generator with Github pages

#coding
Published

August 11, 2025

Modified

December 7, 2025

Sometimes I need to share a link to a Google Form or to a webpage. Usually web addresses, especially those that are easy to create (e.g., a new Google document), are not very intuitive and cannot be easily remembered.

For example this link https://docs.google.com/document/d/1MkHqE-JyUPxVfT0qvrHtUohfIzsD6IZKQQlQB8RQ/edit?tab=t.0 is a really important link that I want to share or that I want to open frequently. I have few options:

There are several services for doing this, but I wanted a really minimal and free tool. When you activate GitHub pages on a repository, each folder in the repository will be a folder in the web address.

For example, let’s imagine a repository structured in this way:

myrepo
  folderA
    index.html
  folderB
    index.html
  folderC
    index.html

The corresponding website will be username.github.io/myrepo/folderA, username.github.io/myrepo/folderB and so on. Basically each folder with a index.html will correspond to a web page called as the folder.

At this point, the index.html can be a redirect HTML page that when opened, redirects to the desired website. A minimal redirect page could be:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Redirecting...</title>
    <script type="text/javascript">
        window.location.href = "URL";
    </script>
</head>
<body>
    <p>If you are not redirected, <a href="URL">click here</a>.</p>
</body>
</html>

Where URL is the target web page. Clearly the redirect can be improved adding a countdown, a custom web page and so on. In this case, the redirect will be direct, without intermediate steps.

The only problem is that creating those links is not really immediate with GitHub pages. My idea was to use a really simple Python script taking links from a json file and creating automatically the folders and index.html files using GitHub actions. Basically you just update (also directly on GitHub web) the json file and after pushing changes the redirect will be ready.

This method is implemented into the filippogambarota.github.io/url repository. You can simply use the repository as a template and update the links.json file. The format is really simple:

[
  {
    "from": "custom url", // this is the custom url (i.e., the name of the folder)
    "to": "real url"      // the real url that will be reached
  }
]

The core of the process is the links.py file that basically read the links.json and create folders and index.html files.

Enjoy :)