It is pretty simple indeed. Took me less than 5 minutes to create a crude Google Sheet that can make bulk short links for me using YOURLS.
The core code is this:
Put this in A2 cell. And paste the link you want to shorten in A1 cell. A2 cell should update to show the short link.
To create short links in bulk, just copy the content of A2 to more rows in the A column and repeat the process.
It's not pretty but it works!
--
Update:
Turns out this is not good enough. There are a few more modifications I have made to this script now that I have used it for a few days. First one is to not get Google to process the function if the cells are empty. Secondly, YOURLS continue to have issues with non-encoded URLs. It simply removes the arguments after & in the URL and creates a short link. I am not sure if encoding the URL fixes it for all links but it seems to work on the URLs I tried. I could not find a direct way to encode URLs in Google Sheets without creating a custom script. Here is the script that I used:
And then I added a second column to convert all links to encoded format. This A2 cell contain this data:
And then I added this code to A3 cell:
Hopefully this works!
The core code is this:
Code:
=importData(concatenate("https://domain.com/yourls-api.php?signature=SIGNATURE&action=shorturl&format=simple&url=",A1,""))
Put this in A2 cell. And paste the link you want to shorten in A1 cell. A2 cell should update to show the short link.
To create short links in bulk, just copy the content of A2 to more rows in the A column and repeat the process.
It's not pretty but it works!
--
Update:
Turns out this is not good enough. There are a few more modifications I have made to this script now that I have used it for a few days. First one is to not get Google to process the function if the cells are empty. Secondly, YOURLS continue to have issues with non-encoded URLs. It simply removes the arguments after & in the URL and creates a short link. I am not sure if encoding the URL fixes it for all links but it seems to work on the URLs I tried. I could not find a direct way to encode URLs in Google Sheets without creating a custom script. Here is the script that I used:
Code:
function encode(value) {
return encodeURIComponent(value);
}
And then I added a second column to convert all links to encoded format. This A2 cell contain this data:
Code:
=encode(A1)
And then I added this code to A3 cell:
Code:
=IF(A1="","***",importData(concatenate("https://domain.com/yourls-api.php?signature=SIGNATURE&action=shorturl&format=simple&url=",A1,"")))
Hopefully this works!
Last edited: