Linktree emulator

código
Imitando un directorio de enlaces sólo con recursos gratuitos
Author

sebastiandres

Published

June 1, 2021

A link directory lets you hand out a single, memorable link that you can update after having shared it. Where, for example, when giving a talk I could say “the code and the presentation will be at this link,” but where it is later possible to add the recording of the talk or the results of a survey. I tried Linktree, but I soon filled it with too many links and it became confusing and hard to navigate. I needed a way to group thematically and with a flexible degree of depth levels. Indeed, if someone is not interested in topic “X” they probably would not be interested in the video of “X,” the code of “X,” the presentation of “X” in html or pdf.

Format offered by linktree (left) versus what I needed and had to create (right). I needed a way to have a link directory with a memorable name, easy to share and customize, but allowing different levels of grouping to be kept. Additional challenge: When it comes to online resources, I am an extreme cheapskate. So I was looking for a solution that I could implement without recurring monthly costs.

As an extreme cheapskate I even thought about making several linktree accounts and linking them to each other, but it was not a scalable solution (and I would have to remember which email and password I used for each link). So, between a mix of embarrassment and laziness, I ended up discarding the idea. The solution hit me all at once. Github allows showing static html pages. I could make a simple html page that emulated linktree and that I could store in each repository on github! The central link would still be on linktree (lintr.ee/sebastiandres in my case) and the links would point to the plain htmls of each github repository. It is a good mix, because linktree is fairly friendly and has some administration tools such as enabling/disabling links. I started by reviewing linktree’s code, but it was excessively long and confusing. So I got to work and started building a solution incrementally.

*** Sixth (and last) version**: General review of the code to optimize and clean it up. Some unnecessary css properties are removed. There are 3 files: The main file is index.html where the links are defined, and the files latest_style.css (style) and latest_copyright.html (emulator version) are used. Each new page with links only needs to define the links, the style and copyright are already defined! Problems detected: Nothing for now.

Sneak peak:

What does the code look like? The first version mixes the code and the style. It makes updating multiple files tedious and error-prone (but it was a quick version to develop and self-contained).

<!DOCTYPE html>
<html>
    <head>
        <style>
            html {background-color:#3d3b3c; font-family: Karla, sans-serif;
                  font-size: 16px; font-weight: 700;}
            h3, h2, h1 { color:#ffffff; margin-bottom: 16px; text-align: center;}
            div {position: fixed; top: 25%; left: 50%;
                -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}
            a {text-decoration: none!important;}
            p  {background-color:#ffffff; color:#3d3b3c; line-height: 56px; width: 676px;
                border: 2px solid rgb(255, 255, 255); margin-bottom: 16px; text-align: center;}
            p:hover {background-color:#3d3b3c; color:rgb(255, 255, 255);}
        </style>
    </head>

    <body>
        <div>
            <h1>Emulador de Linktree</h1>
            <h3>Enlaces</h3>
            <a href="https://linktree-ixkge.ondigitalocean.app/demo1.html" target="_blank">
                <p>Primera versión</p>
            </a>
            <a href="https://linktree-ixkge.ondigitalocean.app/demo6.html" target="_blank">
                <p>Última versión</p>
            </a>
            <h3>Enlaces</h3>
            <a href="https://linktr.ee/sebastiandres">
                <p>⇦ linktree</p>
            </a>
        </div>
    </body>
</html>

The latest version allows changing the style and copyright centrally, and worrying only about the content.

<!DOCTYPE html>
<html>
    <head>
        <link href="https://fonts.googleapis.com/css2?family=Karla:wght@300;400;600;700&amp;display=swap" rel="stylesheet">
        <link href="https://linktree-ixkge.ondigitalocean.app/latest_style.css" rel="stylesheet">
    </head>
    <body>
        <div>
            <h1>Emulador de Linktree</h1>
            <h3>Enlaces</h3>
            <a href="https://linktree-ixkge.ondigitalocean.app/demo1.html" target="_blank">
                <p>Primera versión</p>
            </a>
            <a href="https://linktree-ixkge.ondigitalocean.app/demo6.html" target="_blank">
                <p>Última versión</p>
            </a>
            <h3>Enlaces</h3>
            <a href="https://linktr.ee/sebastiandres">
                <p>⇦ linktree</p>
            </a>
        </div>
        <!-- Version - dont change this code-->
        <object data="https://linktree-ixkge.ondigitalocean.app/latest_copyright.html" width=100%></object>
    </body>
</html>

And how does it all look in the end? It looks like this:

Lessons learned:

Separating content and form is essential to save work. Even for a small project like this one, it helps enormously to avoid duplicating work and to make updates to N pages easier.

The first version, which had 80% of the functionality, took me 20% of the time invested. But the remaining 80% of the time taught me many things I did not know about html and css, mime types, and it was very valuable.

Creating Github pages for each repository is very practical, but it has certain limitations so that people do not abuse it by creating static pages and use it as a free webserver. There are some sites to serve css and javascript with the correct MIME type (https://raw.githack.com for example), but they do not update automatically. DigitalOcean allows spinning up static sites at zero cost and with automatic updates, and keeping everything synchronized.

Links of interest: * https://linktr.ee/sebastiandres: My link directory, the site I wanted to imitate. linktree-ixkge.ondigitalocean.app: Static website, serves as a demo of “how it would look” and to store/link the css and copyright. * https://github.com/sebastiandres/linktree: Repository with the different versions of the code. You can take the latest version of html, css and copyright and customize it to your liking. * Things to improve? Many! Suggestions and comments welcome!