Templates (rev 2)

Last edited by itadmin · 6d ago

Templates

Templates enable reusable content. A template is just a page in the Template: namespace.

Creating a template

Create a page named Template:YourName. Add content like:

Hello {{{1}}}, welcome to {{{2|the wiki}}}!

Parameters are referenced as Template:{1} (positional) or Template:{name} (named). Template:{name} gives a default value when the parameter is omitted.

Transcluding a template

Use Template:YourName to render the template with arguments.

Examples

Infobox:

{{Infobox
| title = Page Title
| image = File:photo.jpg
| caption = A photo
}}

Navigation:

{{Navbox|prev=Prev Page|next=Next Page}}

Self-transclusion

A template can invoke itself, but infinite recursion is prevented (max depth 8). Circular references are detected and broken.

Categories: Documentation