Help:Contributing/templates: Difference between revisions
No edit summary |
|||
| Line 3: | Line 3: | ||
A template is a regular static page living under the reserved namespace <code>Template</code>. | A template is a regular static page living under the reserved namespace <code>Template</code>. | ||
You create/edit a template exactly as you would do with any other classic MediaWiki pages. | You create/edit a template exactly as you would do with [[Help:Contributing#Page_management:_creating,_moving,_deleting_pages|any other classic MediaWiki pages]]. | ||
== Any page can embed one or more template(s) == | == Any page can embed one or more template(s) == | ||
Revision as of 06:06, 21 August 2026
A template is like any other page
A template is a regular static page living under the reserved namespace Template.
You create/edit a template exactly as you would do with any other classic MediaWiki pages.
Any page can embed one or more template(s)
The magic, is that MediaWiki automatically makes all templates embeddable, including in other templates. All you need to do is to call {{template name}}
For instance, if you have created a simple template named Template:Hello, which contains one simple phrase:
Hello! How is it going? It is good to see you!
And then in another page, say, User:DogFood, you write:
{{Hello}}
I am a dog lover! Hope you are as well!
You would get the rendered page:
Hello! How is it going? It is good to see you!
I am a dog lover! Hope you are as well!
Use templates whenever you want to repeat something often
If you are, say, creating a series of articles on your secret recipes, and you want to include a disclaimer at the top of each article, you will probably want to create a template called Template:EvaRecipeDisclaimer, then include the template by writing {{EvaRecipeDisclaimer}} at the top of each of your articles, rather than manually copying and pasting the same disclaimer onto all articles in the series one by one.
This way, if you later decide to change the disclaimer, you only need to update the template, not every article!