I have a MediaWiki template that I want to use in other templates, but I want the first template to add <onlyinclude> tags to the other templates it gets used in.

Unfortunately these tags get processed on the first template, so they ever get included in the target template.

How can this be done?


  • TemplateA: content is <onlyinclude>{{{1}}}</onlyinclude>
  • Article1: Article 1 {{TemplateA|Hello}}
  • Article2: Article 2 can say {{:Article1}}

I would like this to appear as:

  • Article1: Article 1 content is Hello
  • Article2: Article 2 can say Hello

The problem is the <onlyinclude> tags get processed on TemplateA whereas I want them to get passed through to Article1 and processed on Article1 instead.

  • It might be best if you describe what goal you are trying to achieve so that we can recommend a better way to achieve it.
    – Tgr
    Feb 8, 2015 at 21:42
  • @Tgr: See my answer here. I want to have the <onlyinclude> tags appear automatically, without editors having to remember to include them every time they add an infobox to a page.
    – Malvineous
    Feb 11, 2015 at 2:28
  • No, I mean what you ultimately want. Store information about an article in such a way that it can be reused in the article text?
    – Tgr
    Feb 11, 2015 at 2:58
  • @Tgr: I ultimately want data to be entered into infoboxes across multiple pages, and then have a summary page that lists all the pages in a table, along with information about each page in the table columns, where that content is extracted from each infobox.
    – Malvineous
    Feb 11, 2015 at 3:07
  • 1
    I was just about to recommend Semantic MediaWiki but I see at the other question that you found it already. While it is possible to use native templates to build complex data structures, it is almost always a bad idea :-)
    – Tgr
    Feb 15, 2015 at 7:03

1 Answer 1


This little trick should work since the noinclude is applied on the first generation and then the onlyinclude gets only processed at the second parsing.


This needs to be tested (I don't have a test Mediawiki anymore) and it might not work on all Mediawiki versions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.