Savvy Google users know you can restrict your search to a particular Website using the syntax site:[site] [search term(s)]
. For example, a Google query of site:macworld.com "ipad case"
will search Macworld.com—and just Macworld.com—for pages that include the specific phrase ipad case. While many sites provide their own search feature, I find that Google’s searches often provide better results. I also like
Google’s options for narrowing down your search.
The thing is, I tend to use this site-specific search while I’m already browsing the site in question; for example, I’m reading an article on
Daring Fireball and I decide I want to search for articles containing the phrase App Store that Macworld contributor John Gruber has written. I could open a browser window to Google.com, or click in my browser’s search field, and manually type site:daringfireball.net "app store"
, but there’s an easier way using a JavaScript bookmarklet, which is a bookmark containing JavaScript code that’s run when you “open” the bookmark.
In your Web browser, create a new bookmark containing the following JavaScript code as the URL:
javascript:Qr=prompt('Search%20Site%20for','');if(Qr)location.href='http://www.google.com/search?&q=site:'+encodeURIComponent(window.location.hostname)+'+'+escape(Qr)
In Firefox, view the Organize Bookmarks window, click the action menu, and choose New Bookmark; paste the above code into the Location field. In Safari, it’s easier to drag the URL from any site into the Bookmarks Bar, then open Safari’s Bookmarks view and replace the site’s URL with the above code. Whichever browser you use, name the new bookmark something obvious, such as Google Site.
Now, whenever you want to perform a Google search on just the current Website, you use that bookmark, type your query into the dialog that appears, and click OK (or press Return). I’ve been using this trick for years, and it comes in handy multiple times each day.
But if you’re using Apple’s Safari browser, it gets better. Way back in 2003, we published a hint about accessing bookmarks in Safari’s bookmarks bar using keyboard shortcuts. Starting at the left-hand side of the Bookmarks Bar, the first nine bookmarks—not folders or groups, but individual bookmarks—can be opened by pressing Command+1, Command+2, Command+3, and so on, respectively. You can take advantage of that hint to make today’s hint even easier: Place your new Google-search bookmarklet in one of the first nine positions in Safari’s bookmarks bar. Now you can search the current Website by simply pressing the appropriate keyboard shortcut.
Personally, I’ve named my bookmarklet GS (for Google Site, only shorter, so it doesn’t take up so much space in my bookmarks bar) and put it in the third position from the left. Whenever I want to search the current site, I just press Command+3, type my query, and press Return.