jekyll / jekyll-help

NO LONGER MAINTAINED. USE JEKYLL TALK INSTEAD.
https://talk.jekyllrb.com
146 stars 19 forks source link

Implementing shorturls? #6

Closed ndarville closed 10 years ago

ndarville commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

@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 commented 10 years ago

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 commented 10 years ago

@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 commented 10 years ago

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

troyswanson commented 10 years ago

@parkr On second thought, maybe not, huh?

parkr commented 10 years ago

Yurrrrp.

ndarville commented 10 years ago

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

parkr commented 10 years ago

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 commented 10 years ago

Bingo. :raised_hands: