Help:Transclusion
Transclusion is the core concept that powers templates in MediaWiki. It allows content from one page (usually a template) to appear dynamically on another page, without having to copy and paste it. Isn’t that cool?
What is Transclusion?[edit | edit source]
Templates are like reusable building blocks. Instead of repeating the same information across multiple pages, you define it once in a template and insert it wherever it's needed.
Think of it like a function in code:
{{TemplateName}}
This one simple line pulls in the entire content of the Template:TemplateName
page.
Need to update a banner or a layout on 100 pages? Just update the template—it’ll reflect everywhere instantly. Efficient, consistent, and easy to maintain.
Basic Usage[edit | edit source]
To transclude a template onto a page, just type:
{{ExampleTemplate}}
To pass parameters:
{{ExampleTemplate|name=Fen|type=Admin}}
In the template code itself, you would use:
'''User:''' {{{name}}} '''Role:''' {{{type}}}
Transcluding Other Pages (Not Just Templates!)[edit | edit source]
You can even transclude the content of any regular page:
{{Help:Editing}}
But be careful, this can create unexpected side effects if used outside of documentation or meta pages.
Nesting Templates (Templates Using Other Templates)[edit | edit source]
Templates can also transclude other templates. This is known as nesting, and it allows complex templates to be broken down into smaller, reusable components.
For example, a template like Template:Userbox
might call another template like Template:Userbox/core
to handle its layout:
{{Userbox/core | border-c = #aaa | id = Example | info = This is a nested template }}
This keeps logic separated and easier to maintain. It also enables shared styling or behavior across many templates without repeating code.
Why Use Transclusion?[edit | edit source]
- ✅ Centralized maintenance
- ✅ Uniform formatting
- ✅ Clean, readable wikitext
- ✅ Dynamic content reuse
What It’s Not[edit | edit source]
- It’s not copying and pasting content.
- It’s not permanent—changes in the source reflect everywhere.