Include control
Three tags control which parts of a page are used when it’s included, and which parts show on the page itself. They’re most useful on template pages — documentation that shouldn’t be included, markup that should only be included.
The three tags
<noinclude>…</noinclude> shown on the page itself; DROPPED when included
<includeonly>…</includeonly> hidden on the page itself; included normally
<onlyinclude>…</onlyinclude> if present, ONLY these fragments are includedThe semantics in one table:
| Content is inside… | On the page itself | When included |
|---|---|---|
| (no tag) | shown | included — unless an <onlyinclude> exists anywhere on the page |
<noinclude> | shown | dropped |
<includeonly> | hidden | included |
<onlyinclude> | shown | included — and everything outside is dropped |
The typical template page
<includeonly><div class="notice">{{{1}}}</div></includeonly><noinclude>
This template renders a notice banner. Usage:
{{Notice|Your message}}
</noinclude>Viewing the template page shows the documentation; including it produces only
the banner. (The { entities show a literal {{…}} in the usage line —
see Including pages.)
<onlyinclude> is the inverted tool: instead of marking what to hide, it
marks what to share. If a page has any <onlyinclude> block, including that
page pulls only those blocks — handy for reusing one section of a normal
article (a shared intro, a stats box) without restructuring the article
itself. Multiple <onlyinclude> blocks are all included, joined in order.
Details that matter
- Tags don’t nest inside themselves, and each needs its closing tag —
an unclosed
<includeonly>won’t hide anything. - The editor’s preview shows the page view, never the included result: on
a template page, preview hides
<includeonly>content and shows<noinclude>content. To see the included result, preview an edit on a page that includes it. - Include control applies wherever a page is included from — Template namespace or a regular page via the fallback alike.