FamilySearch Wiki:Template namespace

Introduction to templates
Templates often look like text boxes with a different background color from that of normal text. They are in the template namespace, i.e. they are defined in pages with "Template:" in front of the name.

For example, consider the template Template:Disambig (follow the link to see the page where it can be edited). To insert the template's content into an article, type  in the wiki page ("  " is called a template tag). Every article with that tag in it will display the following text:

This technique is commonly known as . Templates can also include calculated and substituted elements, as well as parameters, allowing for complex usage. For a table of some useful templates, see FamilySearch WIki:Template messages. For detailed templating documentation see Help:Template.

Usage
Names can be made up of more than one word, e.g. . The first character (only) is not case-sensitive, so  and  are the same template, but  and  are not.

Templates can also accept template parameters which are then inserted into the output of the template.

Templates used in pages from the article namespace provide information to help readers. These can include navigation aids, or warnings that content is sub-standard. Templates that provide information only of service to editors belong on an article's talk page.

With the template namespace it is possible to include the contents of a page in that namespace within a page in a different namespace, using double curly braces around the template title (for example, would import Template:Title). This is used to:
 * place recurring messages (such as those to denote stubs, disambiguation pages, etc.) into articles in a consistent manner;
 * insert boilerplate messages for various issues like copyright violation, neutrality disputes, etc., using a simple shortcut command; and
 * create navigation templates and sidebars to link series of related articles together.
 * create infoboxes

Templates should not masquerade as article content in the main article namespace; instead, place the text directly into the article.

Templates should not be used to create lists of links to other articles when a category or a See also list can perform the same function.

For further instructions on using this namespace, and for more information about it, please see.

Usage in discussions
Sometimes you will want to refer to a template, rather than actually invoking it. An easy way to do this is to use the "template link" template, Template:Tl. So to discuss the Cleanup template rather than insert the template itself, typing " Cleanup " yields the result "Cleanup". This notation makes clear that you are discussing a template and gives a link to the template itself.

New template creation
To create a new custom message, simply create a page in the Template namespace, named Template:, followed by a name for the message, that contains the text of the message. Names can contain spaces, and initial case is irrelevant; note that template names are easy to remember if they follow standard English spelling, spacing, and capitalization (also see the naming conventions for articles). Try to avoid having templates whose names differ only in casing, spacing, or punctuation. To create such a page, enter http://wiki.familysearch.org/en/Template:Name of your template in the address bar of your browser and edit the page. An alternate method is to create a link something like  on your user page or in the sandbox and then click on it.

Adding a template to a page
To add a template to the page, simply type the name of the template with two braces on each side. For example, to add Template:Wikify to a page, type.

If a template takes a number of parameters, it can be helpful for the following layout to be used when the template is called:

Putting each parameter on a separate line, with the equals signs aligned vertically, helps editors to decipher the wikicode.

Dynamic or full substitution (subst:)

 * Main article: FamilySearch WIki:Substitution

There are two major ways to include custom messages,   and .   makes a copy of the message text and places it where you put the tag after you save an article (substitution). Without "subst", the message will be loaded and put on the page every time you view it, a process known as transclusion.

In other words, when the message is updated, you do not need to update a page that uses it if you use  . As a guideline, short temporary messages that will be removed soon should be copied using subst (which has the advantage of showing the message in the wiki source), and standard notices that might remain on a page for months or forever should be transcluded for easy updating. (You should not use   for a message which contains any links which may change in the future. This method doesn't refresh "What links here" unless every article containing the    gets changed after the modification of the link in the message.)

If you need to edit the template message individually after you put it on your page, use subst. If you don't need to edit it, and would rather the message is automatically updated along with changes made to the template, don't use subst.

For an example of how to substitute variables at the time of their inclusion see the subst magic section in Help:Variables.

Template documentation
A template can sometimes be difficult to use by only looking at the source of the template, so you are encouraged to document your template.

There are two different ways to do this.

One alternative is to use &lt;noinclude&gt; to include a minor description direct into the template, for example: This is a article.&lt;noinclude&gt; Place this template on any article that requires description. It takes one parameter, an adjective used to describe the article. For example, produces the text, This is a bad article. &lt;/noinclude&gt;

Another alternative is to create a /doc subpage for the documentation (preferred for templates with multiple parameters etc.) and add  below the actual template.

A caution about line breaks
Note that some templates may accidentally cause extra linebreaks in the rendered articles. This is especially true of infobox templates and other template boxes that usually float on the right side of an article, since the additional lines will not be seen on the template page.

As a general guideline, avoid two linebreaks together in your template. These may "add up" with other linebreaks in the article and be displayed as unwanted white space.

Sandbox for experiments
If you wish to experiment with templates (and not have your experiments deleted before you are done with them), you may do so in the Template sandbox. You may also use the templates X1, X2, X3, X4, X5, X6, X7, X8 and X9 for experimental purposes. To include a test template, use the form for template X1,  for template X2, etc.

Searching in the template and template talk namespaces
To search in the template or template talk namespaces only, put "template:" or "template_talk:" before the search term. For example, this URL searches for "transclude" in the template namespace while this one searches for "transclude" in the template talk namespace.

It is possible to manipulate the URL to allow searching in both the template and template talk namespaces. E.g.

FamilySearch WIki template search for regnum searches the Template and Template talk namespaces for "regnum".

See Help:Searching for more information.