Main Page

From Wikitemplates
Jump to navigation Jump to search

Welcome to Wikitemplates, the free template repository for all MediaWiki wikis!

How to use wikitemplates in your wiki

To start using wikitemplates in your wiki, you'll need to be an admin, or get one to help you, and do the following:

  1. Enable Extension:Interwiki if it isn't already
  2. Visit Special:Interwiki in your wiki and add Wikitemplates as an interwiki. You must use "wikitemplate" as the prefix and tick the "Transclude" checkbox!
  3. Set $wgEnableScaryTranscluding = true; in your LocalSettings.php

Once you've done this, create local templates in your wiki and call the wikitemplates from there using the syntax {{raw:Wikitemplate:Name of the template}}. You'll need to define and pass the parameters you're interested too. For example, to use Template:Edit in your wiki, create a local template called "Template:Edit" (or any name you like) with the following wikitext:

| page = {{{page}}}
| text = {{{text}}}

Then you can use your local Template:Edit as a regular template. This process also allows you to rename parameters and set default values! For example, in a Spanish wiki you could do:

| page = {{{página}}}
| text = {{{texto|editar}}}

Available wikitemplates

Wikitemplates (with capital W) is the project, while wikitemplates (with lowercase w) are the templates developed here and meant for use in other wikis. Here is a list of the wikitemplates available so far:

Best practices

Developing good wikitemplates is tricky and there're many things to consider. Here are some current best practices:

  • Design the template in the most generic way possible, so that it's useful for the greatest amount of wikis. External wikis can then build more specific, custom templates using the generic ones.
  • Wrap the template output with an HTML tag (<span>, <div>, etc) and add a class to it following the pattern "wikitemplate-name-of-the-template" (example). This will avoid conflicts with existing CSS rules and allow external wikis to easily target the wikitemplate with custom CSS and JavaScript.
  • Internationalization and localization — All text strings should default to English, but be parameterized to allow for localization and customization.


  • Naming convention — User lowercase and dashes in parameter names, for example access-date rather than accessdate, access_date, accessDate, access date or any other variant. There's no good reason to prefer one naming convention over the others, but there's good reason to prefer some convention over no convention. Lowercase-dashes is one of the most common throughout the wikiverse. External wikis may of course change the convention when calling wikitemplates from their wikis.
  • Anonymous parameters — Avoid anonymous parameters to prevent bugs when the parameter value contains = signs (very frequent in URLs). Named parameters also make it easier for users to understand their meaning without referring to the documentation, and avoids parameter order confusion.
  • Default values — In regular templates, something like {{{text|default}}} will output "default" if the "text" parameter is omitted or set to an empty string. However, when that same pattern is used in a wikitemplate, and an external wiki calls the wikitemplate with the "text" parameter set to an empty string, then "default" will not output. For this reason, you need to use the following pattern instead: {{#if:{{{text|}}}|{{{text}}}|default}}


  • Other templates — When calling a wikitemplate from another wikitemplate, you must use the {{raw:Wikitemplate:Foo}} syntax, else the template will not work in external wikis. These hardcoded dependencies are the reason why the interwiki prefix must be "wikitemplate" in all wikis.
  • Template styles — Unfortunately, template styles called from wikitemplates won't work in external wikis. In principle, we could use template styles and instruct users to copy-paste the CSS into their wikis, but this could lead to trouble if we change something here and the external template self-updates but the CSS doesn't. Also, such explanations would be confusing to new users, and copy-pasting stuff is exactly what this project aims to avoid. Lastly, we could instruct users to import the CSS using an @import rule in their template style, but this feature doesn't seem to work, even though it should (phab:T315667). Therefore, we're stuck with inline styling for now.
  • Lua modules — Unfortunately, Lua modules called from wikitemplates won't work in external wikis. Again, we could use them and instruct users to copy-paste the module into their wikis, but this is undesirable for the same reasons explained above. So it seems we're stuck with templates and inline styling. That's unfortunate, but then again, we were stuck with them for years before Lua modules and template styles appeared.