Setting a keyword gives the bookmark a useful property: if you type that keyword in the URLbar and hit return, Firefox will go straight to that bookmark. If you're a commandline user, that's already a win -- it's easier for some of us to remember a word like "yahoo" than to navigate a bunch of hierarchical bookmarks menus.
Now comes the important part. Replace the term you searched for, banana, with %s in the Location field (figure 1). Go ahead and dismiss the dialog -- you're done with it.
The magic "%s" tells Firefox, "Replace me with a string supplied by the user." You'll supply it by typing it in the URLbar. Try it now. Go to the URLbar -- Control-L is a handy shortcut that takes you there and highlights whatever's there so you can replace it, but doesn't overwrite your X selection in case you want to paste. Type yahoo bookmarklets and hit return. Firefox should take you straight to the Yahoo's search results page for "bookmarklets": http://search.yahoo.com/search?p=bookmarklets. Neat! It even works for multiple search terms and quoted strings.
You can use the Keywords trick to set up bookmarklets for all sorts of different searches, like Google Images at http://images.google.com/images?q=%s, Google Maps at http://maps.google.com/maps?q=%s, and Wikipedia at http://en.wikipedia.org/w/wiki.phtml?search=%s. Getting the Wikipedia search URL is a little tricky, since their search redirects you to a wiki page, not a search results page. Sometimes you have to poke through View->Page Source, or ask around to see if anyone else has already figured out a query.
Simple bookmarklets are also great for developers and QA people who need to access online bug systems. I have bookmarklets for several different Bugzillas: if someone references a Mozilla bug by number, all I have to do is type in mozbug 233853 and it goes straight to https://bugzilla.mozilla.org/show_bug.cgi?id=233853, while gimpbug 120829 will do a comparable search in GIMP/Gnome's Bugzilla.
These examples all have simple URLs, but they don't have to. I once built up a complex Google query to find XKCD cartoons by keyword: xkcd %s site:xkcd.com -site:forums.xkcd.com -site:fora.xkcd.com -site:blag.xkcd.com. Of course, I saved it as a bookmarklet. Now any time I want to search for a cartoon, all I have to do is type xkcd keywords.
This article was first published on Linux Planet.