Monday, December 12, 2011 9:13 PM Jan Tielens

URL Shortening For SharePoint 2010

I’m pretty sure everybody who is using SharePoint has sent a link to a document in a Document Library to somebody else (in an email message for example). So you probably know that links to documents (or list items) can become pretty long if the document is located in a Document Library on a site deeply buried in a hierarchy. SharePoint is of course not the only platform having this “issue” and the internet already solved it quite some time ago with URL shortening. From Wikipedia:

URL shortening is a technique on the World Wide Web in which a Uniform Resource Locator (URL) may be made substantially shorter in length and still direct to the required page. This is achieved by using an HTTP Redirect on a domain name that is short, which links to the web page that has a long URL. For example, the URL http://en.wikipedia.org/wiki/URL_shortening can be shortened to http://bit.ly/urlwiki or http://tinyurl.com/urlwiki. This is especially convenient for messaging technologies such as Twitter and Identi.ca, which severely limit the number of characters that may be used in a message. Short URLs allow otherwise long web addresses to be referred to in a tweet. In November 2009, the shortened links on one URL shortening service were accessed 2.1 billion times.

So to make a long SharePoint URL short, you can copy the URL to the clipboard, got to a URL shortener, past the long link over there and copy the short URL you get in return back to the clipboard. Works perfectly, but there are quite some tedious steps to go through. Already a long time ago, when SharePoint 2007 was still the rage, I posted some code that automates all these steps. Finally I found some time to update the code to SharePoint 2010 and nicely package it in a Sandboxed Solution, so it works both for SharePoint 2010 deployed on premises as in the cloud on Office 365. The result looks as follows, in the Documents tab of every Document Library, a new item is added to the Share and Track group (the button gets enabled when one document is selected):

When the Get Short Link button is clicked, a call to the Bit.ly URL shortener is made. The short URL is returned, together with a QR code, in a dialog for easy copy/pasting:

You can download the solution (.WSP) from the Get Short Link for SharePoint CodePlex site for easy deployment. Over there you can also find the complete source code, so feel free to enhance and improve! If you feel like sharing back, let me know and I’ll try to include your enhancements in the project. A couple of remarks:

  1. I used the Bit.ly URL shortener because it has a nice API and some cool features (like the QR code generation). You can adjust the source code to use your own Bit.ly account or even another shortener.
  2. The code uses the jQuery Javascript library (because I’m still a lazy developer and I still love jQuery a lot). The latest version of jQuery is included in the solution and automatically deployed.
  3. The solution and the source code are provided “as is” and without warranty of any kind. So please test before you deploy it to your mega big and important SharePoint site. It works on my machine(s). :-)

Side note: if you still follow this blog after a long period of blog-silence: thanks for your patience and welcome back. I won’t make any promises but I really would like to pick up blogging and start contributing again to the fantastic SharePoint community. Feel free to send some comments to encourage me. :-)

Filed under: ,

Comments

# re: URL Shortening For SharePoint 2010

Tuesday, December 13, 2011 2:41 AM by Bart Kuppens

Hey Jan, I have been following your blog for a long time and I'm glad to see that you're bacj. Thanks for the solution. This will make sharing SharePoint links a little less painful. :)

# re: URL Shortening For SharePoint 2010

Tuesday, December 13, 2011 3:20 AM by Jeroen Ritmeijer

Nice solution, but are you sure you want to store your potential confidential file names in a public service such as bitly, e.g. 'Proposed merger between Shell and BP.docx'?

# re: URL Shortening For SharePoint 2010

Tuesday, December 13, 2011 4:26 AM by Barbara

Thanks, and welcome back "big" Jan :-)

# re: URL Shortening For SharePoint 2010

Tuesday, December 13, 2011 7:52 AM by Donal

Nice!

Will it work with ordinary lists?

# re: URL Shortening For SharePoint 2010

Monday, December 19, 2011 4:20 AM by Jan Tielens

Jethro, this is Sandboxed Solution, so you have to deploy it via the Solutions Gallery in the Site Collection settings page!

# re: URL Shortening For SharePoint 2010

Thursday, December 22, 2011 4:29 AM by Mark

Hey Jan,

I have used your site for years and you have provided lots of help so glad you are back.

This is a great post, satisfies my customers obsession with short urls!

Mark

# re: URL Shortening For SharePoint 2010

Sunday, January 8, 2012 11:53 PM by College term Papers

Magnificent post my friend, it is really a new information I have collected from here.

# re: URL Shortening For SharePoint 2010

Wednesday, January 18, 2012 10:46 AM by Chetan

There are options to program your own url shortner, then you wouldn't need the Bit.ly. You can host it on your server and use this solution to link to the internal url.

# re: URL Shortening For SharePoint 2010

Friday, January 20, 2012 5:29 AM by Roger B

Try this solution to keep the url secure and within your own environment www.sharepointshorturl.com.