Template:Gs

From Angelina Jordan Wiki

Documentation

This template provides a convenient way of linking to a Google search. It properly URL-encodes its input (unless told not to) and makes it obvious that the link is to another website. Pages containing calls to this template (possibly provided via other templates) can be found by using the "WhatLinksHere" feature.

The template does not complain about missing input; instead, it uses the name of the page calling the template as the search query if no other text has been specified.

The name of this template is based on the phrase "google search".

This template is used on a great many pages. Making any changes to it will cause lots of jobs to be added to the processing queue.

Usage

Basic calls:

  • {{gs}}
  • {{gs|search string}}
  • {{gs|search string|text to be linked}}
  • {{gs|q=search string|linktext=text to be linked}}

The parameter q is equivalent to the first positional parameter (the search string), and takes precedence over it if both are provided. If neither are provided, the page name is used as the search string. Similarly, the parameter linktext is equivalent to the second positional parameter and takes precedence over it if both are provided. You can use either of the shorter names text or t instead of linktext. If no link-text is specified in any of these ways, the search string (or, if necessary, the page name) is used for that.

Additional parameters:

  • {{gs||no-encode=|site=|encl=|open=|close=|pre=|post=|show-icon=}}

These named parameters can be used with any of the basic forms above.

If the automatic URL-encoding of the search string is causing problems, you can turn off that feature by setting no-encode to any true value. In such a case, you will almost certainly need to provide your own encoded version of the search string in q and an unencoded (or perhaps differently encoded) version in linktext. This can be tricky to get right, but fortunately it is rarely needed, since the automatic encoding works seems to well most of the time.

The parameter site can be used to narrow searching to a specific website.

The parameters encl (standing for "enclose" or "enclosure"), open, close, pre, and post all refer to things (usually single characters, but not necessarily) that will appear before the little "leaving the wiki" arrow indicator but outside of the link itself (see the examples below). Any combination of these parameters can be used together (so, for example, you could use encl and close without open, if that's necessary for some reason).

Examples

As seen in the first two examples, if no search string is specified, the page name is used. (The name of this page is "Gs". Hover over the link to see the URL being linked to, if this is possible in your browser.)

The last example is only there for "completeness", to show the order of encl, open, close, pre, and post, when used together.

Other ways of using quotation marks that don't work as well:

These last two examples use external links, just for comparison. But using "bare" external links like this is discouraged on this wiki.

The link in the second example is broken at Wikipedia (the relevant article there does not have quotation marks). The first and fourth just look weird. The third and fifth look better (the previous remark about bare links notwithstanding) and work fine, but are tedious to implement, and a bit error-prone.