Robustify Unstable Links with Google
At work, I’m the maintainer of some company internal standards. Some of them link to a section of of our public online documentation. The system that produces this doc doesn’t produce cool URLs. They are long, ugly, and change every time we do a major software release.
Q: How can I get out of the business of updating these URLs every six months? A: Hack Google’s “I’m Feeling Lucky” button.
Google crawls our site regularly and will always know where this page lives. If I tell Google what I want to link to, it will always know what the right URL is. By inspecting the HTML behind Google’s submit form, I came up with the following procedure.
First, figure out a search query that will always return the page you want as the first result. Here is what I typed into Google’s search box:
"Marking Up Text in Cells for Publishing" site:www.mathworks.com
I’m using two good search tricks here. First, I use quotes to surround the exact title of the section of the doc I want to reference. These individual words appear all over the doc, but this exact phrase is only on this page and pages that reference it. Secondly, I use the site:
directive so the results will include only results for our website. I use this trick all the time (usually via the “Search only items on the current Web site” button on the Google Toolbar). Between the two of these, I can feel confident of finding the exact page I want.
I press “I’m Feeling Lucky” and confirm that Google indeed takes me to the desired page. Now I need to hack a URL that will do the same thing. I go back to the search page and press the usual “Google Search” button. Copy the URL in the search bar to use as your link, which looks something like this:
http://www.google.com/search ... &btnG=Google+Search
If you used this as-is, clicking on the link would bring you to the Google Search results. To make it skip the results and go straight to the first result, we just need to tweak it a little. Find “btnG” in the URL and change it to “btnI”. Now the link will take you straight to the desired page
Ned posted on 2007-05-08 (source):
Nice! I didn't know it was so straightforward to use the Lucky Button result. This is the quick-and-dirty semantic web in action. Trust in Google and all else follows.Nabeel posted on 2007-06-19 (source):
Maybe it's late, but I'm not seeing what this saves you. Aren't you just replacing your ugly url with a slightly less ugly Google one? I thought you were moving toward url rewrites, but then you changed directions on me. The clock link is great. I'm always forgetting the time difference in other countries, this is a huge help. Now if they could make this into one of those desktop widgets, sort of like what the Mac has (or what I've heard Yahoo makes for PCs). That would be really helpful. Nice to see you blogging again! What's the story for this Halloween??? I'm looking forward to seeing your and Stuart's pics.Matthew posted on 2007-07-23 (source):
Nabeel, using this technique you can create a link that will point to the same content, even if the URL itself changes from under you.