User:Bruce A/Template guide

I'm not an expert template creator, but in creating templates for the wikis I contribute to, I've learned some things that I'd like to share that I don't feel are covered in other guides I've seen.

My approach to templates
I want templates I create to:
 * Have visually consistent design
 * Be as unobtrusive as possible
 * Be easy to edit
 * Be modular (meaning, they can be tweaked easily)
 * Look good

The two types of templates
There are basically two types of templates that I know of:
 * 1) Templates that add articles to categories. These are used to help categorise pages on a wiki. Examples include:
 * 2) Templates that don't. E.g.
 * 1) Templates that don't. E.g.

The structure of a template
The templates I create consist of: You will usually want most of those things in templates you create, but you can omit some things if you want once you know what each aspect does.
 * 1) Template code
 * 2) Categories the pages with the template will be added to (if any)
 * 3) Code that stops anything below from appearing in the template
 * 4) Explanation of how to use the template
 * 5) Helpful links related to the template (i.e. a "See also" and "External links" section)
 * 6) Categories the template page will be placed in
 * 7) Explanation code, to make the code easier for people to read and understand

Let's go through each of those by looking at an actual "page stub" template, which I like to call "Needs expansion" (as in, "This article needs expansion") rather than "Stub" or "Page stub" since I try to minimise jargon.

How to use this template

 * Place &lt;nowiki&gt;  at the top of pages that need expansion.
 * They will be placed in the Needs expansion category, so people who want to help expand it can do so.

5. Helpful links related to the template

 * If you want to test out this template and practice using it without fear of breaking something, use the Sandbox page.
 * Full list of the templates on this wiki

7. Explanation code
Explanation text goes between this code:

Anything between those arrows won't be treated as code.

I like to add some symbols around the text, so it's easier to differentiate explanations from the code itself:

Putting it all together
The final result:

How to use this template

 * Place &lt;nowiki&gt;  at the top of pages that need expansion.
 * They will be placed in the Needs expansion category, so people who want to help expand it can do so.

The basis of the templates I create
I use a pre-created template as the basis for most templates I create.
 * This is what it looks like.


 * This is the code for it:

How to use this template

 * Place &lt;nowiki&gt;  at the top of pages that need expansion.
 * They will be placed in the Needs expansion category, so people who want to help expand it can do so.

Creating a template: a step by step guide
Let's start with something simple: a citation needed template that you can use

This one is simple because it doesn't need you to edit

1. Create a new page

Create a new page for your template.

Call it "Template:Template Name Goes here"

There must be no space between "Template:" and the name of the template, or it won't work.

2. Edit the page

Click "Edit" on the page. That will take you to the visual editor

3. Add the code

Copy and paste the following code, and paste it into the page:

&#91;Citation needed &#93;

How to use this template

 * Place &lt;nowiki&gt;  next to information and claims that need to be cited.
 * Pages with this tag on them will be placed in the Citations needed category, so people who want to cite sources for information in the article can do so.

Respecting copyright
Before using a template, be sure you have a license to do so.

As most wiki content is licensed under a CC-BY-SA license, you can use it on your wiki, so long as you: An easy way to do that is in the edit summary. So when you create the template, write something like:"Created page. Template from Community Central, licensed under a CC-BY-SA license: http://community.wikia.com/wiki/User:Bruce_A/Template_guide?action=history" The reason you link to the history page is because:
 * Name the source (i.e. what wiki is it from?)
 * Link back to the source (Wikia has said linking to the history page of content you're using is from is fine)
 * The history page can be found by
 * Share it under the same license
 * Mention the license it's licensed under
 * It let's people know where they can find the original source
 * Wikis usually have many editors. Naming all of them isn't practical, so linking back to the history page should suffice

Handy tips
No spaces

Template code should have no spaces between it. If you have spaces, when you add templates to pages, that space will carry through to the page, too. Usually you won't want that.

For example:

With spaces:

A

B

C

Without spaces:

A

B

C

Categories

If you want a category to show up properly, sometimes you have to do this:

(I don't know why. But that's how it goes.)