Two weeks ago I told you about the nifty plugin for Safari called Keyword Search. This is the one that allows you to set up little shortcuts to search sites you visit often. I explained that it works really swell with most sites, but not with static sites like Programming By Stealth. PBS is a static site created by simple Markdown files inside a GitHub repository. Bart and I eat our own dog food for the podcast and it keeps managing the information much simpler for Bart.
I went on to explain that I figured out a workaround by adding in a text replacement shortcut in the Keyboard Preference Pane. I was chatting with Bart about it and he came up with a better idea. It’s still a little bit of a workaround because Keyword Search still won’t take you right to the PBS site, but it does have a big advantage over my idea.
By using the Keyboard Preference Pane to create a Text Replacement, I have to maintain that one website search in a completely different tool, which adds cognitive load to my brain which is overloaded on my best day. His alternative will allow me to keep all of my keyword searches in the same tool.
While pbs.bartificer.net can’t do search queries, Google or whatever search engine you favor can search the PBS pages, and it can create that query string we need. It was a little more complicated than I expected but still pretty easy to do. To search the PBS pages (or any site) using your search engine of choice, simply type the search term followed by “site:pbs.bartificer.net”.
Using Google as the example, if I could find out the query string that Google uses for that search, I could put it into the Keyword Search extension with a placeholder.
I typed “module site:pbs.bartificer.net” into Google, and it dutifully returned a set of results. I looked at the URL bar, but sadly it just said “module site:pbs.bartificer.net”, not the search query it used. I started writing a message to Bart about how it wasn’t going to work. I selected all in the URL bar (again that’s just “module site:pbs.bartificer.net”) but when I pasted it into the message, it was the real search query after all! It was extraordinarily long with lots of glop in it:
https://www.google.com/search?q=module+site%3Apbs.bartificer.net&client=safari&sxsrf=APq-WBtebvslWMH-73C-RIzBjrdgfkqT3A%3A1646605654763&source=hp&ei=VjUlYv7xKJzIkPIP9OWasAk&iflsig=AHkkrS4AAAAAYiVDZhfk0ip8vD9YQ4d-HzVzsjvfyG9c&ved=0ahUKEwj-9IaJxLL2AhUcJEQIHfSyBpYQ4dUDCA4&uact=5&oq=module+site%3Apbs.bartificer.net&gs_lcp=Cgdnd3Mtd2l6EANQAFjrF2DGG2gAcAB4AIABYYgBugKSAQE0mAEAoAECoAEB&sclient=gws-wiz
But I looked at the beginning and realized it was really pretty simple. The beginning said:
https://www.google.com/search?q=module+site%3Apbs.bartificer.net
Buried in that I could see the key/value pair “q=module” which is what I searched for. The final step then was to substitute in the placeholder “@@@” for the word “module” and I have my search query ready to plop into the Keyword Search extension.
https://www.google.com/search?q=@@@+site%3Apbs.bartificer.net
If you’d like to be able to search static sites with Keyword Search, or if you prefer seeing your keyword searches inside Google’s interface, just copy this string from my notes and plop it into your own extension. My Keyboard Text Replacement achieved the same result, but keeping track of it in one place is going to be easier. Plus I learned that if I can’t find the search box on a given site, or I’m too lazy to do the legwork, I can always copy this search query and adapt it for any site I like. Best of all worlds!