Template:google

Definition from Wiktionary, the free dictionary
Jump to: navigation, search

The following documentation is located at Template:google/documentation. [edit]


Wiktionary has built-in support for links to Google Web Search results, but this support is a bit buggy, because it's hacked onto support for interwiki links. (Most notably, it changes spaces to underscores in the link, like in Wiktionary article titles; this alters how Google performs its searches. Also, the built-in support doesn't allow any way to include | or OR in searches.) This template offers a better alternative.

Usage[edit]

The template is used rather like the built-in support. The first argument is mandatory; it indicates the string to search for. The second argument is optional; if included and non-blank, it indicates the link text. If the second argument is blank, then the first argument is used for this as well. If the second argument is omitted entirely, then "google:" plus the first argument is used for this:

Search type[edit]

Unlike the built-in support, the template also supports an optional {{{type}}} parameter:

As above, a second unnamed parameter may be included, with the same functionality as above.

Pipes in search queries[edit]

A Google search query can include the pipe character |, which serves to indicate a logical disjunction; for example, a Google search for yes|no will pull up pages that contain either the word yes or the word no (or both). However, the pipe character has meaning to the MediaWiki syntax (it's used to separate template parameters), so care is needed.

Symbol oppose vote.svg This does not work: {{google|yes|no}}no
Symbol support vote.svg This works: {{google|yes OR no}}google:yes OR no
(This is a feature of Google: uppercase OR is equivalent to |.)
Symbol support vote.svg This works: {{google|yes{{!}}no}}google:yes|no
(This uses Wiktionary's {{!}} template.)
Symbol oppose vote.svg This does not work: {{google|yes<nowiki>|</nowiki>no}}|no google:yes|no
Symbol oppose vote.svg This does not work: {{google|yes&#x7C;no}}google:yes|no
Symbol oppose vote.svg This does not work: {{google|yes%7Cno}}google:yes%7Cno
Symbol oppose vote.svg This does not work: {{google|yes&#124;no}}google:yes|no

Note that none of the above approaches works with the built-in support; for example, [[google:yes{{!}}no]] produces no.

Number of results per page[edit]

The optional {{{num}}} parameter may be used to specify a number of results per page; for example, {{google|search string|num=30}} links to http://www.google.com/search?q=search+string&num=30, which shows the first thirty search results.

However, this parameter should be used with care, since it would override any setting the user may have configured in his or her Google preferences.

See also[edit]