|
How can my Google site search just look in a subdirectory?Hi Dave. Maybe I've missed this somewhere, but how do I get the search to only look at one directory in my domain? I'm looking for it to only search files in my help file, but not to look in the rest of the site. I'm unsuccessful. I looked at that bot thing, and i didn't see an answer [cf how to add a Google search box to your site] So, for example, it currently looks at www.mywebsite.com, but I want it to look at www.mywebsite.com/directoryA. Is there a way to do that? Entering that path simply returns 0 results. This is a tricky problem, actually, because as you have noticed Google doesn't allow you to constrain searches to just a specific subdirectory on a site, even when you go directly to their search engine. A good way to see what you can and can't do, by the way, is to both check out the Advanced Search Page and the oh-so-helpful list of search operators. Noodling on this, however, there are a couple of ways you could try to address the problem... :-) First off, the operator intitle: is interesting. It lets you specify search results that contain a specific word or phrase in the title of the page. If your FAQ pages have a unique set of words in the title, perhaps "Help Pages", then you could try to use that constraint. For example, search for turkey dinner and look at the top four or five matches. Now search for turkey dinner intitle:recipe to see what I mean. Even better, though, is if you have a specific subdirectory name, you can try using inurl: to constrain search results to just those matches in that area of your site. It's not foolproof, as a quick test with turkey dinner inurl:recipe reveals (that is, some of the matches are because the word appears in the filename, rather than as a subdirectory) but I imagine you can work around that by having a more complicated directory name. For example, instead of a potentially recurring word like "help" try "helpdir", which is unlikely to appear in the name of a file elsewhere on the site. So that's a reasonable, workable search solution, one that will certainly let you do searches on Google itself for just that subset of files you desire. How do you implement it as part of the search box? That's a bit more tricky because we have to splice together two strings in the Javascript (or pre-load "inurl:helpdir" into the text field, a potentially easier solution). That's something I'll address tomorrow, then come back and add a link to that article here. Stay tuned!
Categorized:
CGI Scripts and Web Site Programming
(Article 7814,
Written by Dave Taylor)
Tagged: google search, search hacks, site search Previous: How do I add a second site to my Google Analytics account? Next: Modifying search strings on Google site search? Subscribe!
Thanks Dave. I look forward to the solution. My directory is called V9.0, so that's at least a name that won't appear in my files. The directory does have multiple sub-directories that I'd like to also have Google search. I'm hoping the solution sets the search to that directory and all subdirectories... Posted by: Victoria at January 4, 2008 8:41 AMI hope you continue too. Of course, I could spend a year just reading everything you have already posted. But my votes for “keep blogging�. Posted by: Tim at February 11, 2008 1:03 PMCould you send me the code for including the google search in my website? Posted by: jestin davis at July 2, 2010 4:07 AMI have something to say, now that you mention it, but ...
I do have a comment, now that you mention it!
|
Recommended
Recent Entries
Search
I Need Help!
Apple iPad Help
Articles and Reviews Auctions and Online Shopping Blogs and RSS Feeds Building Web Site Traffic Business and Management CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above Facebook Help Google Plus Help HTML and CSS Industry News and Trade Shows iPhone and Cell Phone Help iPod, Sony PSP and MP3 Player Help Mac OS X Help Pay Per Click (PPC) Advertising Search Engine Optimization (SEO) Shell Script Programming Tech Support Video Help The Writing Business Twitter, LinkedIn and Social Network Help Unix and Linux Help Video Game Tips and Help Windows PC Help WordPress Help |