FANDOM


Cookie cutter

A template works just like a cookie cutter.

Templates are pages that help you say or display the same thing over and over again. Think of them as virtual cookie cutters, on a mission to stamp out the same thing many different times.

Since templates can be included in many pages, they can promote a uniform style across pages, as with infoboxes it's very simple. They can also help you leave the same message on many pages like you might do when trying to make an announcement to a handful of users. And they can make a single page a lot easier to read and maintain, as when the main page is formed by just a few discrete templates.

In short, templates are extremely useful tools, vital to the efficient running of any wiki.

Basic facts

Templates are located in the Template namespace. This includes any page with a name beginning with Template:, such as Template:Whatever.

Template pages are created and modified using the source edit mode, but most can be inserted into pages using any editor interface. That said, you'll likely have better luck inserting complicated templates on pages by using source mode.

You must be logged in to edit templates.

Finding and using templates

New Fandom communities come with pre-loaded default templates. You can view a complete list of templates available on your community by going to Special:AllPages and selecting "Template" from the namespace dropdown menu. Click "Go" and all available templates will appear in a list.

Once you've figured out what templates you have to work with, you can begin thinking about how to use them in their most basic form. The instructions are slightly different for each editor Fandom offers:

Template Insert VE

Insert a template with the VisualEditor using this dropdown.

  • In the default VisualEditor, click on the bolded word INSERT found in the top middle of the page. Then click "Templates" from the dropdown list, or begin by typing {{, to bring up a list of templates, and then search for the name of the template you want.
  • In source edit mode, you can use the code {{Template name}} to add any template to your page.
  • In the classic editor, you can also select from the list of all templates available on your community by clicking "Add other templates"

How to create a basic template

Templates can be very powerful, but also sometimes very complicated. It often helps to start by creating the simplest possible kind of template, and then experimenting from there.

  • On your community, navigate to "Template:Example" using the address bar of your browser and click "Create" which can be found in the top right corner of the content section. This will open source editor to create the template.
  • You should see a popup asking you to Choose template type; check one of the options. If none match to what you're are looking for, check "Unknown".
  • Type a couple of words or a sentence in the editor.
  • Click "Publish". You have just created a template with some sample content.
  • On your community, create a new article called "Template test".
  • The next step to add the template to a page varies based on your chosen editor. See this section for more info.

You've successfully created and used a template! Now you can change the content of your template and add it to more pages to make it more useful for your community.

Advanced templates

Template parameters

Rachel VE template

Selecting parameters in VisualEditor's template tool

Templates can have parameters. These allow you to alter the way the template is displayed, such as including specific text or altering the design.

To take Template:Wikipedia as an example, adding just {{Wikipedia}} assumes that the page on Wikipedia is the same name as the page of the current page the template is used on. However, a parameter can be added to tell the template that the page on Wikipedia has a different name, for example Microsoft. In source edit mode, the code to add this parameter is {{Wikipedia|Microsoft}}, though in VisualEditor, the same is achieved by clicking on a template and editing the parameters.

It is possible to change the output of a template based on what the user inputs when editing the template in source editor.

To learn more, see Help:Template parameters and Help:Parser functions.

Substituting templates

A different way to use a template is to substitute its content into a page. This can only be done in source editor, and is done by inserting subst: immediately after the opening braces: {{subst:templatename}}. Once the page is saved, the link to the template is removed and the template output is substituted in its place and can be further edited. Any updates to the template will not affect the content that was substituted into the page.

To learn more, visit Help:Substituting templates.

Lua-based templates

There are alternatives to wikitext templates that provide particularly advanced templates, which may be more comfortable or performant for advanced users and software coders, in the form of Lua-based templates implemented in the Module namespace. While more complicated to code, these templates can perform faster and can be more readable. It is also possible to import existing Lua-based templates from the Fandom Developers Wiki' own Global Lua Modules list.

To learn more, visit Help:Lua.

Copying and updating templates

Contributors throughout Fandom have made all different kinds of templates. It is often simpler to copy an existing template and modify it for your needs, rather than creating one from scratch. Great places to start looking for templates are established wikis about a topic closely related to your own. For instance, if you're a TV wiki, look at other TV wikis you admire, particularly those in your topic's own genre.

In most cases, you are free to copy templates based on the shared CC-BY-SA license. Giving credit to the community from which you copied the template is vital.

Templates

Here are some basic steps to copy most templates:

  1. Find the template you want to copy.
  2. Click the Edit button, select all of the wikitext, and copy it.
  3. Create a new template page on your community.
  4. Paste the wikitext code you copied and leave behind a edit summary which credits the wiki from which you obtained the template. Then, press the Publish button.

Template documentation

Many templates have a separate subpage for documentation about the template. If this is the case you might want to bring the documentation across as well. The process is pretty similar to copying the template itself.

  1. Find the template documentation you want to copy.
  2. Click the "Edit" button, select all the wikitext and copy it.
  3. Create a new template documentation subpage page on your community.
  4. Paste the wikitext code you copied, credit the donor wiki in an edit summary, and press the Publish button.
  5. Often, examples given in documentation can be specific to a particular wiki, so make sure the examples make sense for your wiki.

See also

Further help and feedback

Community content is available under CC-BY-SA unless otherwise noted.