Setting Up Infobox Templates in MediaWiki

Note: This guide has been updated as of 2014-09-22 for MediaWiki v1.23. If you’re using this version (or later) please see the Infoboxes in MediaWiki v1.23 post.

** Click here for the updated post. **


If you’ve ever been to any of the more structured Wikipedia pages you probably have seen the neat “infoboxes” that they have on the right hand side. They’re a neat, convenient way to get some of the core metainfo from an article.

If you have your own MediaWiki instance, you’ve probably thought they’d be a nice thing to have, so maybe you copy and pasted the code from Wikipedia and then were surprised when it didn’t just magically work. Turns out that the infobox stuff is part of MediaWiki’s extensive Templating system, so first of all you need the templates. Sounds easy, right?

Well, no. You don’t just flip a switch or download a file, and when you do a search you might find this article which details a process that it says might take 60-90 minutes.

I started looking into it and quickly got lost; you basically need to create a billion different Templates and do all sorts of weird stuff to get it to work. Fortunately I stumbled across this discussion which contained a clue that greatly simplifies the process.

I was able to distill the steps down to a process that I was able to reproduce on a new MediaWiki install in about five minutes. Before we start, I’ll throw in the warning that I have not read the documentation and I don’t understand at a low level what is happening with the templating. I just wanted a working, simple infobox.

  1. Download the MediaWiki extension ParserFunctions and add it to your LocalSettings.php as referred to there.
  2. Copy the CSS required to support the infobox from Wikipedia to your Wiki. The CSS is available in Common.css. You’ll probably need to create the stylesheet – it will be at http://your_wiki/wiki/index.php?title=MediaWiki:Common.css&action=edit – and then you can just copy/paste the contents in there. (I copied the whole file; you can probably just copy the infobox parts.)
  3. Export the infobox Template from Wikipedia:
    1. Go to Wikipedia’s Special:Export page
    2. Leave the field for ‘Add pages from category’ empty
    3. In the big text area field, just put in “Template:Infobox”.
    4. Make sure the three options – “Include only the current revision, not the full history”, “Include templates”, and “Save as file” – are all checked
    5. Hit the ‘Export’ button; it will think for a second then spit out an XML file containing all the Wikipedia Templates for the infobox for you to save to your PC.
  4. Now you have the Template, you need to integrate them into your MediaWiki instance. Simply go to your Import page – http://your_wiki/wiki/index.php/Special:Import – select the file and then hit ‘Upload file’. NOTE: see update at the bottom of the page before doing this.
  5. With the Templates and styles added you should be able to now add a simple infobox. Pick a page and add something like this to the top:{{Infobox
    |title = Infobox Title
    |header1 = Infobox Header
    |label2 = Created by
    |data2 = David
    |label3 = External reference
    |data3 = [http://trog.qgl.org trog.qgl.org]
    }}

The full infobox Template docs are available here – there’s a lot of stuff in there, but if you just want a really basic infobox then this is the simplest way I found to get them working.

I tested this on two separate MediaWiki installs – one running v1.12.1 and one on v1.15.1 – and it worked on both of them, but as always YMMV.

Update 2013-07-27

As many people have noticed, the guide no longer works. Thanks to commenters jh and chojin, it looks like you also need to do the following:

  • Install the Scribunto extension and add it to your LocalSettings.php as usual. It looks like this extension is now required for the InfoBox templates (in fact, it looks like it replaces ParserFunctions entirely, but I’m still testing that).
  • The XML file that is output in step 3 appears to erroneously (?) use text/plain as the format type. If you edit this XML file in your text editor and replace all incidents of ‘text/plain’ with ‘CONTENT_FORMAT_TEXT’ (I only found two), the import will be successful and the infobox tags looks like they work.

If someone else can confirm this for me as a working solution I’ll revise the original post so it takes these steps into account.

91 Responses to Setting Up Infobox Templates in MediaWiki
  1. Matty Zee

    I’m getting a similar error to others. The import seemed to go ok but i get a “Internal error”, “[22a3b0b9] 2013-09-04 06:07:08: Fatal exception of type ScribuntoException”

    So I enable error loggin in Scribunto by adding this line to my LocalSettings.php
    “$wgScribuntoEngineConf[‘luastandalone’][‘errorFile’] = ‘/tmp/lua-error.log’;

    This gave the following output:
    “extensions/Scribunto/engines/LuaStandalone/binaries/lua5_1_5_linux_32_generic/lua: Syntax error: “(” unexpected”

    It seems the binary i’m using has an error, or more likely, isn’t correct for my platform. (i’m running this on a Raspberry Pi)

    Not sure what to do now, i’m looking for binary suitable for an ARM processor. But the Scribunto page says that only Lua 5.1.x is supported and that looks pretty old.

  2. Chris

    The revised steps work perfectly for me (although, three incidents of text/plain in the exported XML, guess Wikipedia’s been busy) using a freshly-installed, self-hosted Mediawiki on Linux.

  3. brian

    Does anyone have a version they would like to share that is working with templates et all. I cannot seem to get the 1.21.2 version working with scribunto; so ergo no templates.

  4. Matty Zee

    Sorry, I forgot to say in my previous post ‘thankyou’ to for putting this tutorial up and keeping it up to date! Much appreciated.

    As an update, it turns out Lua is included in the Raspbian Wheezy distro. So all i needed to add was the following line to my LocalSettings.php

    $wgScribuntoEngineConf['luastandalone']['luaPath'] = '/usr/bin/lua';

    Now i have infoboxes working on my Wiki running on my Pi :-)

  5. Leu

    Thanks for the tutorial. I ran into that error Zee mentioned, but I found a website that described a fix.

    “Fatal exception of type ScribuntoException” FIXED!

    If the server is running on Linux, go to your Extensions folder using an FTP client and change the permissions settings for the “lua” file so that it will be executable:

    Extensions/Scribunto/engines/LuaStandalone/binaries/lua5_1_5_linux_32_generic/lua

    Change the permission of the file to 755 (which makes it executable)

    If the Linux version is 64 bits, change the lua file in the 64 bit folder inside the same binaries folder as the 32 bit file.

  6. asert

    The problem with Scribunto you will fix if you just download the LATEST (“not stable”) version of Scribunto.

    Nice guide btw.

  7. CJ

    Thanks for this tutorial. I was able to get a mobile instance of xampp up and running with Infoboxes! Like Chris I had 3 cases of text/plain to replace. When I uploaded the first time it took a long time so I stopped the upload and checked any recent changes. I restarted the server and uploaded again and bingo, infobox capability was there. Thanks again.

  8. GBAllison

    Frustration level is pegged. Without question, your guide is closest to an actual working guide. Comparing against

    http://www.mediawiki.org/wiki/Manual:Importing_Wikipedia_infoboxes_tutorial
    http://www.etcwiki.org/wiki/Install_infobox
    http://www.blogercise.com/adding-infoboxes-to-mediawiki-powered-sites/

    I also notice that way at the very bottom of this:
    http://en.wikipedia.org/wiki/Template:Infobox
    It says: “The infobox template requires the Scribunto extension and HTMLTidy to be installed.”

  9. GBAllison

    That said, I’m completely stuck. I’m on the newest MediaWiki 1.21.2, the newest ParserFunctions 1.5.1, the newest Scribunto, I’ve followed all the instructions–starting with the main tutorial, as updated. Like others, I get three text/plain replacements when I edit the Template:Infobox and Template:Infobox/doc export xml. I’ve changed ALL the lua executable permissions to 755.

    Then I started going through the comments, one by one and trying everything. I added and/or commented out:
    $wgDBmysql5 = false;
    $wgGroupPermissions[‘user’][‘import’] = true;
    $wgGroupPermissions[‘user’][‘importupload’] = true;
    $wgScribuntoDefaultEngine = ‘luastandalone’;

    Also, I learned that if you repeat the import multiple times–even though you’re importing the exact same file–eventually some of the errors go away. As though something in the import is dependent on something else in the import.

    I also find that it’s important to reset the browser cache after each change to the LocalSettings.php file. But eventually …

    The import always fails. I’m not getting the text/plain error any more. But the errors break down into two distinct groups:

    ERROR ONE … I get this on the screen and nothing else

    Warning: proc_open() [function.proc-open]: open_basedir restriction in effect. File(/dev/null) is not within the allowed path(s): (/home/marshall:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp) in /home/marshall/public_html/chappysnibs/extensions/Scribunto/engines/LuaStandalone/LuaStandaloneEngine.php on line 134

    Warning: proc_open(/dev/null) [function.proc-open]: failed to open stream: Operation not permitted in /home/marshall/public_html/chappysnibs/extensions/Scribunto/engines/LuaStandalone/LuaStandaloneEngine.php on line 134

    Fatal error: Call to a member function getStatus() on a non-object in /home/marshall/public_html/chappysnibs/extensions/Scribunto/engines/LuaStandalone/LuaStandaloneEngine.php on line 10

    ERROR TWO I get the Special:Import results screen, the main part of the screen has a big red lien that says

    Import failed: Expected mediawiki tag, got

    And overwritten over the entire screen are two additional lines that say

    Warning: XMLReader::open() [xmlreader.open]: Unable to open source data in /home/marshall/public_html/chappysnibs/includes/Import.php on line 51

    Warning: XMLReader::read() [xmlreader.read]: Load Data before trying to read in /home/marshall/public_html/chappysnibs/includes/Import.php on line 449

    I’ve spent way too many hours on this (so what else is new :-) … anyone have any idea what might be going on? Do I really need HTMLTidy? Do a thousand import attempts mess things up so badly that I should just rebuild the whole wiki from scratch and start clean? Any suggestions? Thanks!

  10. fazeela

    Thank you ,This one worked for me

  11. Mark A. Hershberger

    In the future, if you come across a problem like this, please file a bug.

    I’ve filed one: https://bugzilla.wikimedia.org/56249

    Please add any details that I missed.

  12. fazeela

    there were 3 text/plain in the xml i have generated

  13. shorto

    Just confirming that the new way works.

    Great job, tnx!

  14. Steve

    Confirmed that this work in MediaWiki 1.23a with GoMediaWiki free skins.
    text/plain occurred 7 times.

  15. BroncoKrawler

    Receiving the following error. Any ideas?

    Lua error in package.lua at line 80: module `Module:HtmlBuilder’ not found.
    Backtrace:
    (tail call): ?
    [C]: in function “error”
    package.lua:80: in function “load”
    package.lua:99: in function “require”
    Module:Infobox:7: in main chunk
    (tail call): ?
    (tail call): ?
    [C]: in function “xpcall”
    MWServer.lua:73: in function “handleCall”
    MWServer.lua:266: in function “dispatch”
    MWServer.lua:33: in function “execute”
    mw_main.lua:7: in main chunk
    [C]: ?

  16. fazeela

    @BroncoKrawler can you please check lua is installed in your system correctly

  17. Zach and Michael

    We’re running almost stock MediaWiki on Windows 7 and Apache. Your updated instructions worked perfectly! Thank you.

    We ran into an issue of, when we were trying this ourselves we had already created the Template:Infobox page. When you import it doesn’t automatically overwrite what we already had. We had to delete our existing page (logged in as sysops) and then it imported perfectly.

  18. Michael

    Thank you so much for this easy to follow guide! I did encounter one hiccup though… I initially got a ‘Script Error’ that read ‘Lua error: Internal error: Unable to decode message.’ To fix this, I simply had to download the latest master version of Scribunto (I had previously installed the 1.21 version as I’m running MW 1.21.2) – now it works.

  19. jason

    It appears that you can no longer export the info box template.

  20. Ryan Kraus

    Awesome documentation! Super useful.

    I kept getting a Script Error the said the following:


    Lua error: Internal error: The interpreter has terminated with signal "11".

    This is a Scribunto problem where the Lua binary distributed with Scribunto is crashing for one reason or another. This can sometimes be fixed by using a Lua binary that is already installed on the server. This can be done (on most Linux based servers) by putting the following in the config file:


    $wgScribuntoEngineConf['luastandalone']['luaPath'] = '/usr/bin/lua';

  21. asdf

    THANK YOU. extremely crucial instructions. terrible documentation and tutorials on template setup elsewhere. you saved me a lot of time. I am grateful

  22. Brandan Borgias

    I’m having trouble getting Scribunto & Lua to work.
    * I have the latest Scibunto extension that includes Lua.and binaries.
    * All Lua executables and paths are 0755.

    I still get error message:
    Exception from line 114 of /…wikipath—/extensions/Scribunto/engines/LuaStandalone/LuaStandaloneEngine.php:
    The lua binary (/…wikipath…/extensions/Scribunto/engines/LuaStandalone/binaries/lua5_1_5_linux_32_generic/lua) is not executable.

    Installed software:
    MediaWiki 1.22.4
    PHP 5.3.27 (cgi-fcgi)
    MySQL 5.0.96-community
    Lua 5.1.5

    Any suggestions?

  23. AK

    Hi I got the msg box to work following the post – however the images for the msg box types are not available — I only have Ambox_notice.png

    How can I get the others .

    | type = critical / serious / warning / notice / / move / protection

  24. shorto

    Any tutorials by you how to make an infobox template? :)

  25. THANKS

    Thanks a whole lot, your 2013-07-27update definitely worked for me. The Infobox looks so cool I’m so thankful.

  26. Henry Sullivan

    I’ve run across many of the issues mentioned in the above comments, and have managed to fix many problems, BUT I still get Script error on all of my templates and on many of my modules.

    Script error appears twice on Module:Infobox:
    Lua error in Module:Message_box at line 20: attempt to index field ‘text’ (a nil value).
    Backtrace:
    (tail call): ?
    Module:Message_box:20: in main chunk
    (tail call): ?
    (tail call): ?
    [C]: in function “xpcall”
    MWServer.lua:73: in function “handleCall”
    MWServer.lua:266: in function “dispatch”
    MWServer.lua:33: in function “execute”
    mw_main.lua:7: in main chunk
    [C]: ?

    I can’t help but feel that overcoming that error will involve solving my last big problem. Anyone else run into this problem?

  27. Olivier

    It seems to work but when I click on a template, I always have script error “Error Lua in mw.html.lua in line 345: Tag name must be a string.

    I push the common.css, the Scribunto and Parserfunctions extensions.

    Any idea ?

  28. Riggan

    This absolutely does not work.

    I followed this guide to the last detail, step by step, no mistakes. First I got a lua error. Added the codes to my LocalSettings.php file as recommended from the Scribunto extension page and my entire wiki went down. Sighted a fatal error with the lines the chmod and chcon codes are on. Removed those only to find none of the templates import correctly. All have script errors and are not working. Tried to import them again. No change.

    Looks like this post has been pretty much abandoned. So, this is for any new reader such as myself who was hoping to find an easy solution to get a simple stupid box working on your page. This does NOT work.

  29. trog

    I actually tested it again about a month ago and it worked fine (I updated the blog post with some minor edits, I think).

    Can you provide some more information about what you’re working on? e.g., are you using MediaWiki from source or from package? What versions of the extensions did you use?

  30. Riggan

    I’ll answer your questions as best I can:

    I’m using 1.24.1 MediaWiki via a one-click install from Dreamhost. So I assume that means it was a package, but not 100% sure.

    I’m using the extensions from the direct links you provided. I followed this guide down to the last detail and did everything it advised to do.

  31. Riggan

    Now I’m getting an error similar to this when I try to import the XML file containing the templates:

    “Warning xml reader::open unable to open source data in line 53”

  32. John

    This used to work!, Now with MW 1.25.2 an import generates a server 500 error after a few minutes.

  33. John

    Trog, thanks for the great tutorial, after installing the neccessary template and Scribunto, on my mw 1.23 LTS instance, and following other modified instructions as outlined at the end of your tutorial, I am getting a script error report like this:

    Lua error in mw.html.lua at line 253: Invalid class given: The name must be either a string or a number.

    Backtrace:

    (tail call): ?
    [C]: in function “error”
    mw.html.lua:253: in function “addClass”
    Module:Infobox:234: ?
    (tail call): ?
    mw.lua:567: ?
    (tail call): ?
    [C]: in function “xpcall”
    MWServer.lua:87: in function “handleCall”
    MWServer.lua:301: in function “dispatch”
    MWServer.lua:40: in function “execute”
    mw_main.lua:7: in main chunk
    [C]: ?

    Are you able to make heads or tails of this, and what may be going on? In place of my infobox I get a red Script error.

    Thanks for any clarification Trog.

  34. trog

    It’s been a while since I tested this so it’s quite possible the guide is now out of date due to version changes in some of the dependent libraries. I’ll try and have another crack to see what I can find but not sure when I’ll have a chance, sorry!

  35. John

    No problem Trog! I’ll check in from day to day to see if you have gotten to it. Thanks for your time and consideration!
    John

  36. John

    Trog, I found the issue as discussed at https://www.mediawiki.org/wiki/Thread:Extension_talk:Scribunto/Scribunto_Script_Error

    I simply loaded Scribunto for mw ver 1.24. for my 1.23 instance, this gave me the latest functional version for 1.23, and the info box works now.
    I have not tried Scribunto for mw 1.26, it may work as well.

  37. José Bonilla

    @trog – I have not read all the comments and I realize this article is old, but I can confirm that, by integrating the last step discussed in the article before importing the template XML, it works flawlessly in MediaWiki 1.26.

    Thanks a lot for the guide!

  38. trog

    Thanks José!

  39. REIFY

    The XML file had more like 20 instances of ‘text/plain’ when I looked.

  40. trog

    It’s quite possible it has changed a lot since I wrote this originally!

Leave a Reply

Your email address will not be published. Please enter your name, email and a comment.