This page looks best with JavaScript enabled

The Tag That Shall Not Be Named

 ·  ☕ 5 min read

MediaWiki has three tags that can be used for “partial transclusion.”1 Partial transclusion means to transclude only part of a page, for example:

<includeonly>Hello, world!</includeonly><noinclude>{{documentation}}</noinclude>

Here, if you transclude the template, you will see Hello, world!. You will NOT see {{documentation}}.

Compare to:

Hello, world!{{documentation}}

When you transclude this page, the entire text will show up, both the Hello, world! and also the {{documentation}}.

Types of partial transclusion

MediaWiki supports a few types of partial transclusion:

Indeed The Tag That Shall Not Be Named is so important not to name that I’m NOT EVEN BACKRONYMING IT. That should tell you something.

Source of confusion

If you look elsewhere than this blog post, you may find the true, hidden name of The Tag That Shall Not Be Named. You will see that it takes the two words of <includeonly>, a nice, sane tag, and exactly reverses them. But it’s okay, you can remember the difference because…….

……..no you can’t. There is no mnemonic here. The only way to know the difference is to “just know” the difference. So, my opinion is that you should learn about includeonly and noinclude (and I guess maybe LST (Labeled Section Transclusion) if you really want to) and nothing else until you are sufficiently confident with these that you can start to introduce The Tag That Shall Not Be Named into your vocabulary.

Partial transclusion from non-template pages & why you shouldn’t

Some pages may do something like:

<noinclude>
A bunch of text here, blah blah blah
</noinclude><!--

-->Some cool chart or graph here!!!!!!!!!!!!<!--

--><noinclude>
The rest of the page
</noinclude>

Someone might want to do this in order to avoid code duplication; if this mainspace page has noinclude around everything except for the cool chart or graph, they can cheat the system and transclude THAT ENTIRE PAGE to another article. That other article will then show ONLY the chart or graph and none of the surrounding page content. Awesome, right??

NO! This is BAD and you should NOT DO IT! In actuality this page probably looks like this:

<noinclude>
A bunch of text here, blah blah blah
== A heading above the cool chart or graph ==<!-- change here! -->
</noinclude><!--

-->Some cool chart or graph here!!!!!!!!!!!!<!--

--><noinclude>
The rest of the page
</noinclude>

So, when someone new to editing goes to section-edit the heading, they are confronted with a closing <noinclude> that seems pretty out of place. The confused hapless new editor confronts this tag and says “I don’t understand this, I will delete it” and then deletes it. Suddenly, the other page, the one transcluding this cool chart or graph, has the ENTIRE page content3 of the original page. AND a broken noinclude tag at the top! No one wants this, no one is happy.

Note also, that this setup violates my very important principle (VIP) that when you see a piece of information on a wiki, it should be immediately clear to an editor who’s familiar with that wiki where to edit it. But there is no inherent reason why this block of text would come from another page if you are doing a partial transclusion like this. Don’t violate the VIP!!

What to do instead

Instead, place the chart on its own page, where there is no other content. Then:

  • No partial transclusion is needed
  • Someone experienced with the wiki wanting to change the cool chart or graph can always find it
  • But it’s a bit more hidden to a brand-new editor, who might not realize they are editing multiple pages at the same time
  • And if a newer editor does find it, they are not likely to be confused about the wikicode tags.

Whitespace & transclusion

In the example above, you may notice that I have a bunch of whitespace commented out. This is of vital importance. In a template, all whitespace outside of a noinclude must be commented or deleted.

Examples of what to do

The following are all valid:

Example 1

<includeonly>Hello world</includeonly><noinclude>{{documentation}}</noinclude>

Example 2

<includeonly>Hello world</includeonly><noinclude>
{{documentation}}
</noinclude>

Example 3

<includeonly>Hello world</includeonly><!--
--><noinclude>
{{documentation}}
</noinclude>

Example 4

<includeonly><!--
-->Hello world</includeonly><!--
--><noinclude>
{{documentation}}
</noinclude>

Try it yourself

The following code is NOT okay:

<includeonly>
{{#if:{{{1|}}}|{{{1}}}<!-- /if -->}}
</includeonly>
<noinclude>
{{documentation}}
</noinclude>

Fix it to look like each of the examples above!

Solution Like example 1:
<includeonly>{{#if:{{{1|}}}|{{{1}}}<!-- /if -->}}</includeonly><noinclude>{{documentation}}</noinclude>

Like example 2:

<includeonly>{{#if:{{{1|}}}|{{{1}}}<!-- /if -->}}</includeonly><noinclude>
{{documentation}}
</noinclude>

Like example 3:

<includeonly>{{#if:{{{1|}}}|{{{1}}}<!-- /if -->}}</includeonly><!--
--><noinclude>
{{documentation}}
</noinclude>

Like example 4:

<includeonly><!--
-->{{#if:{{{1|}}}|{{{1}}}<!-- /if -->}}</includeonly><!--
--><noinclude>
{{documentation}}
</noinclude>

A bit more on whitespace…

I have a draft of an article entirely about whitespace in templates, so this will be brief.

  • If you write {{#if:{{{param1|}}}|value if true|value if false}} then you can put as much whitespace as you want:
    • On either side of {{{param1|}}}
    • On either side of value if true
    • On either side of value if false
    • Before the #if
    • In between the #if and the :
      You are allowed to do all of these because each argument will be stripped by the PHP function that handles the #if call
  • Any whitespace at all is allowed IN BETWEEN noinclude tags, because you already aren’t including it
  • If you want to use indentation please comment out all new lines as demonstrated above AS WELL AS all space leading up to the first character of your code on that line
  • Particularly when working with table-row templates and Cargo, you may want an empty line at the start of your template if the first line is |- (i.e. new table row)
    • This is not always the case, again generally this will only be with Cargo

Conclusion

Do not talk about The Tag That Shall Not Be Named, and be careful with whitespace. If you bother me enough, I may even write that article! (Please do not bother me about it while I’m in Vienna thanks.)


  1. Normally I would link the mediawiki.org page on this, but you are not innoculated yet. Don’t go there yet. ↩︎

  2. We will not speak of DPL either ↩︎

  3. Well, the first half at least ↩︎

Share on

river
WRITTEN BY
River
River is a developer most at home in MediaWiki and known for building Leaguepedia. She likes cats.

What's on this Page