shortener url github

shortener url github

11.Nov.2021

What is github?

Github is a web-based hosting service for version control using Git. It is mostly used for computer code. It offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features. As of 2014, it is the largest host of source code in the world, with over 20 million users and 36 million repositories (including 28 million public repositories).

I found using github to shortener url

Yes I want to know how you found this article because I think there are many things that can be done on github but here's an example why Github can shorten url . The trick comes from URL Shortener which has been made by GitHub Pages have something to do with this.

As can be seen from the picture above, if you type "https://github.com/maliksahil/gistlyn" into your browser address bar then you will be redirected to this url : "http://www.ur1.ca/" . I think there is no need for any explanation on this because it's pretty clear how URL Shortener works on GitHub Pages (read more ).

Proof of my github account

Before starting this article I want to get some points on the track so that there is no doubt left. So here's something for you to see, by looking at it will be more than enough.

The above picture is an extract of my own Github profile which clearly shows that I'm registered with them and I have two repositories in my account. One of them is in private mode which can not be viewed by anyone , While GitHub Pages in the other one . If you're doubting whether or not these sites are mine then let me tell you that they're 100% mine because I created them myself . All of the images people are uploading are hosted on these two sites, if people don't host images on these two sites then how the hell would this be possible?

Shortener url on github.com

There are many ways to create a short urls using GitHub but the most effective one is creating one through an API which someone can not easily detect unlike if you use other alternatives, for example I use Google's URL Shortener . Here are some steps of creating a short url on github.

Step 1: Create Repository or Project on Github

First thing first, if you want to shorten your existing long url on Github so it must have to be either a project or repository , new repositories can not be used as URL Shorteners unless you enable them manually (see more ). If someone has created their own public repo then they can shorten any public-hosted image on it. If you want to shorten your url using an API then you must create a new project/repository ( see more ).

Step 2: Give some name to your Repository or Project

The second thing is very simple in my opinion, in order to create a Github Page so in the previous step we created our own project/repository but in this step we need to give some names to them . For example if I'm about to shorten "http://www.ur1.ca/" so I will call my project something like that : "maliksahil-shortener" .

Step 3: Clone the Repository

After you've finished naming your repository , now comes cloning part. The first thing you need to do is click on the repository then hit "clone or download" option . This will open a new page where you can see some text area with an input box at the end of it which says something like : https:// (username) @github.com: (projectname).git . All you need to do now is put your username and project name after '@' sign, for example I used my username maliksahil and my project name was maliksahil-shortener so here's what will come out : https://maliksahil@github.com:maliksahil-shortener.git

Step 4: Create a File in the Repository

The last step is creating a file inside the repository , this can be done by clicking on your project or repo and then hitting "New File" option (see more ). After finishing with naming your file simply hit 'Create' button.

Step 5: Publishing Public Image on Github

Once you've finished with creating a new file in your repository , it's time to publish public image through that file because now we're going to create short url using github api . Let me show you that there are many ways to do this but here's the easiest one which requires no coding knowledge : 1- Open browser then navigate to http://github.com/ 2- Login if you have not already 3- Go to any image hosting website for example imgur.com 4- You will see a long url next to the image 5- Copy that url into your new file on Github for example click on your new file and paste it there 6- Now change '.png' to '.jpg' if you want JPG or '.gif' if you want gif 7- Name the file with something like "myimagefilename" 8- Once finished publish the file 9- Go back to browser then hit refresh button 10- Enter your username 11-hit enter , now check your profile one more time 12- See? The image/files published above is now a short link

How this works? I'm sure most of you might be wondering how these steps work, am I right? Well let me explain what I've done in the steps above (list of things) : - Creating our own Repository or Project on Github - Naming our repo/project whatever we want - Cloning repository to local system with username and project name information taken from previous step - Creating new file inside the cloned repository which will act as URL shortener for pasted image url. This method is based on creating a HTML file, if you don't know what html is then... hard luck :( Just kidding, it's very easy to create an html file... try doing it using notepad ++ , it's free software .

- Publishing public image on github Step 6: Using Shortened Link Now comes the fun part , here are some use cases of creating a shortlink on Github : - Using it as a redirect link to your actual website/blog - Using it as a redirect link when sharing or sending someone something (e.g. Instead of saying http://ur1.ca/maliksahil-shortener you can simply say maliksahil-shortener) - As an imgur album name in order to protect images from unauthorized access And much more... I hope this tutorial was easy to understand, if you need any help feel free contact me through comment section . Thanks :)