
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!
Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Simpy.
Categorized:
CGI Scripts and Web Site Programming
(Article 7814)
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!
Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader. 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 PMI have a lot to say, but ...
I do have a comment, now that you mention it!
|
Search
Find just the answers you seek from among our 1700+ free tech support articles by using our Lijit search engine.
Help!
Subscribe to
Ask Dave Taylor!
Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.
Articles and Reviews
Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above HTML and CSS Mac OS X Help MySpace, Facebook, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help
Recent Entries
Join the List!
Book Links
|