Archive:Categories and templates

(Redirected from Categories and templates)
Jump to: navigation, search
This is an explanation document, written by the Web team.

If you want to learn more about world from the perspective of the web team, read other Web team explainers.

All about categories and templates

This wiki makes extensive use of categories and templates.

A category is a list of pages. If you include a special tag on a wiki page, the wiki software automatically places that page in a list of pages that are also in that category. The category gets a page; it always starts with "Category:", like Category:Web team explainer.

At the bottom, every page links to all the categories it is in. Some pages are in no categories; those pages have no links to categories at the bottom.

Sometimes category pages have no content, even there are pages in the category. Then they appear as red links. It's good to put text in the category page so that visitors to the category page know what the category is really for.

To add a page to the Fruit category, you can write
The most popular categories have a template that we ask you to use instead. You can include it like this:

It's an unusual way to do things, but if you keep reading, you'll see why we do it.

The basics of templates: including text

Templates are a feature of the MediaWiki software that runs this wiki. They can be used in simple ways, or in complicated ways.

So I'll explain the simple ones first.

First, you can use them to include verbatim text right into a page. To do that, you can write
{{Sample template}}
and you'll get the contents of that page: this came from the Template:Sample template page

Using templates to mark pages as part of a category

On this wiki, we often use templates to set a page to having a category. Take a look at the Template:Web team explainer document. You should include that template at the top of any page that is a web team explainer. The template does the follow things:

  • It renders a glossy, prominent box by using the top box template.
  • It sets the page to have the "Web team explainer" category.
So, generally, if you want to add a page to a category, you should type
{{The category name}}
at the top of the page.

Advanced use of templates

So there's this rather neat thing you can do with templates called replacing parameters. If you're not a programmer, it's hard to explain, but it might be easy to understand through an example.

If you write this:
{{Top box|the thing I passed in to the template}}
you'll get this:
the thing I passed in to the template

It works because the Template:Top box page has the text {{{1}}}. Literally: three curly braces, the number one, and then three close curly braces. When we include the template and pass the pipe character in, the stuff after the pipe replaces the {{{1}}}.

That's it

That's all that we use on this wiki. If you read the official documentation on templates, you'll discover there are more features. Go figure.