Skip to content
This repository has been archived by the owner on Nov 29, 2017. It is now read-only.

Implementing shorturls? #6

Closed
ndarville opened this issue Mar 31, 2014 · 10 comments
Closed

Implementing shorturls? #6

ndarville opened this issue Mar 31, 2014 · 10 comments
Labels

Comments

@ndarville
Copy link

What is the best and/or easiest way to create base16 shorturls (short urls) mapping from your blog posts to your own domain without relying on services like bit.ly—which don’t protect your links, should the company fail or get acquired?

How have you implemented them on your site?

@troyswanson
Copy link
Member

Hey @ndarville - your question has several avenues that end in different results, depending on which path you choose to travel.

The easiest way is pretty obvious: use a system that already exists (bitly, tinyurl, is.gd, etc.) to create the short URLs. These services - like anything else on the internet - have the possibility of going under, which would cause those shortened URLs to disappear.

Another way would be to host your own URL shortening service. It's way more involved, but obviously gives you total control over the system. The popular self-hosted URL shorteners (YOURS and phurl) are PHP scripts that live on some server that you are in charge of.

Here's another idea: if you are using GitHub Pages and have a server that you'd like to use to help automate the creation of these short URLs, take a gander at the page_build webhook. This hook fires when GitHub publishes your site to their Pages platform, giving you the ability to create a script that crawls the site as soon as it is built and dynamically create shortened URLs as it come across new pages.

Which route you decide to take depends on the level of effort you wish to trade off for the amount of control you want to have over the system.

Personally, I think URL shorteners are very rarely necessary. The only time I need to shorten a link is when I'm sending a tweet, but Twitter does that automatically through its t.co service.

@albertogg
Copy link
Member

@troyswanson @ndarville what about something with jekyll-redirect-from ? I've never used that gem but from my understanding it does redirects from different URLs. I may also be completely wrong.

@troyswanson
Copy link
Member

Same, I've never used it, but I believe it deals with creating redirects within your site, which is only for your own domain. For instance, setting up a "vanity URL" like http://example.com/a-new-hope which would redirect to http://example.com/2014/4/1/star-wars-a-new-hope-review/.

@albertogg
Copy link
Member

@troyswanson yes, but it may work for what @ndarville wants; and as you said, that be, e.g. http://example.com/XdFdE would redirect to http://example.com/2014/4/1/star-wars-a-new-hope-review/ he will just need a rake task or whatever script to generate a draft with the redirect_from: and the base64.

@parkr
Copy link
Member

parkr commented Mar 31, 2014

It would be awesome to have some special keyword built into https://github.com/jekyll/jekyll-redirect-from ... :)

@troyswanson
Copy link
Member

@parkr On second thought, maybe not, huh?

@parkr
Copy link
Member

parkr commented Apr 1, 2014

Yurrrrp.

@parkr parkr closed this as completed Apr 1, 2014
@ndarville
Copy link
Author

So the parting advice is to not involve Jekyll in the process at all?

@parkr
Copy link
Member

parkr commented Apr 1, 2014

My parting advice would be to use jekyll-redirect-from and use more semantic short URL's, rather than the base 64 encoded gobbledy-gook we love so much. ;) E.g. My post "The Crime of Net Neutrality and What We Can Do to Fix It", I'd probably shorten that to redirect_from: /net-neutrality or something. Or, if you wish, you can even make up a lil set of nonsense chars: redirect_from: /b32JakI

@troyswanson
Copy link
Member

Bingo. 🙌

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants