Wikidata talk:Infobox Tutorial

Active discussions

Sample infoboxesEdit

At Wikidata:WikiProject_Movies/Infobox, I tried to list infoboxes using Wikidata relevant to the project.

I still think we should implement Wikidata:Project_chat/Archive/2016/01#Badge_for_templates_using_Wikidata.3F to allow users to find Wikidata infoboxes.

Personally, I find the infobox for people on cswiki a good sample: Find Wikidata-only infoboxes in the Czech Wikipedia. It's not LUA-based though. Interestingly, I don't think I ever found one without any useful data.
--- Jura 09:34, 30 June 2016 (UTC)

@Jura1: Thanks for the comment. I looked at some of the examples and am wondering now, what people think about the different approaches. hu:Sablon:Film infobox seems to do most of its logic using WikiText templates:
-->{{Infobox/Megjegyzés feltétellel<!--
  -->|megj='''{{#if:{{wikidata-f|P1191}}{{wikidata-f|P577}}|{{hányas|{{#time:Y|{{wikidata|{{#if:{{wikidata-f|P1191}}|P1191|P577}}|first=|link=nem|format=iso}}}}}}}} {{wikidata|p495|labelProperty=P1549|lang=hu|link=nem|separator=–|conjunction=–}} {{wikidata|p31|link=nem|first=}}'''<!--
whereas fr:Modèle:Infobox Philosophe just calls a single line of Template code:
<includeonly>{{#invoke:Infobox|build|nom=Philosophe}}{{Infobox en Lua}}</includeonly><noinclude>
and all the logic seems to be happening here: fr:Module:Infobox/Philosophe. Are these the only two approaches currently being taken? --Tobias1984 (talk) 10:25, 30 June 2016 (UTC)

  • The infoboxes at frwiki seem to be well designed, but I tend to get lost in their complexity. When trying to re-use some code, it seems that I would have had to import dozens of modules and sub-modules to use it.
Personally, I mostly edit Template:Property documentation which has the advantage of being built mostly from one module. Once in a while more experienced users such as Matěj Suchánek and Laddo clean up my additions. The cycling specialists seem to have gone quite far with this approach. The number of users who edit the module might be fairly limited.
Given that the approach with #property eventually gets unreadable or comes to parts of Wikidata it can't access, I don't think there is a way around LUA.
Maybe the approach at sv:Mall:Faktamall film WD by Mippzon and Innocent bystander is a possible intermediate solution: data is gathered (and formatted) through (a) module(s) and the layout is left to the original template. This has also the advantage that people don't get bothered by a slightly different layout. In some communities this can be more problematic than the actual use of Wikidata.
--- Jura 10:55, 30 June 2016 (UTC)
The disadvantages of a template like "sv:Template:Faktamall film WD" is that it does not allow complex items.
An example: Laggarberg (Q10553245) is a "Bonnie and Clyde"-item about two villages ("Laggarberg östra" and "Horsta och Laggarberg"). The template "sv:Mall:Ortsfakta Sverige" can handle those, but I fail to see how a "sv:Mall:Ortsfakta Sverige WD" could handle them. Such complex items probably demands a LUA-solution. One option that strokes me now is that we maybe can use a "Switch" in the beginning of the template, linking two or more templates. -- Innocent bystander (talk) 13:01, 30 June 2016 (UTC)
If the site allows arbitrary access, with {{{Wikidataitem|}}} that is passed-on to sv:Modul:Wikidata2? For debugging, this can be useful in any case.
--- Jura 13:38, 30 June 2016 (UTC)

The cycling module "Cycling race" (it is not Version 2, that is the module to develop the code.) has gotten today a new feature, see this. We already have used something like this for another cycling table (at the moment we have 5 different tables + one infobox), but this is more unconventional. This allows us to use WD data as standard data that editors in the article could adapt to special cases. For example a stage was shorten during the race, a rider was disqualificated or there is a rest day. Adding those cases into WD would be possible and we have found some solutions in the code for them, but difficult to insert into WD and to code too. Another use case for this approach is sorting a table after the surname. The cycling module is an international module and therefore the names of the riders are going to be translated and therefore the order typed into WD doesn´t match all Wikipedias. The code to sort the table will be on as the standard in some Wikipedias, but in other WPs it will be an option the editors could switch on in the article. Wikicode and lua/WD could work really well together. Another point, on which so far we have not worked much is SPARQL and bots. In my view, a WD infobox should have tools to see what is happening with the data the infobox is printing. And there should be tools to move data from Wikipedia and from the internet to WD. I have plans to do more on those tools and bots (PAWS) in the future. By the way, there is another WD/Lua module (from frWp) for cycling, therefore different modules have to work with the same wd data. I don´t know what you will learn from this. I don´t think there will be a lot more special purpose wd/lua modules in the future, but a special purpose module is able to have features a general purpose module will nether have. PS: We have used function frame:extensionTag to print WD references in the article. There was a section at Project chat‎ about infoboxes which have this feature. My guess is, that this is a feature Wikipedia editors would love to have. --Molarus 21:09, 2 July 2016 (UTC)

Experience from French WPEdit

Thanks for you initiative. In French WP we already had a lot of discussions and some lua modules already exist (see here and there) but I think this is a good idea to start from the white page instead of reusing a code which was modified hundred times without an objective to keep the code simpler as possible. We are discussing too to define some standards:

  • Harcoded data in the article code should have the priority over WD value
  • It should be possible by adding a specific character or by setting a parameter to avoid the display of the Wikidata value in the infobox. This should be possible for each entry of the infobox
  • Display of the references should be possible for each entry

And from my user perspective I would like to have two modules working together for infoboxes using Wikidata. The first module should be used to extract data from WD and to filter them according to some parameters provided by the contributors (most recent data, only data with external references,...) then the filtered data are transferred to the second module which only structure the data in the infobox. Snipre (talk) 11:24, 30 June 2016 (UTC)

@Snipre: Thanks for commenting. I agree with all of the above and make sure it gets mentioned in the tutorial. I also think it is important that the module can handle data-filtering. For software we usually only want the newest value (the statement that has the qualifier with the youngest date). And sometimes it might be necessary to limit lists (e.g. Limit the list to 10 actors of a movie instead of getting all of them). Module:Filters would be a good name for your suggestion. I will hopefully reach that part of the tutorial sometime this month. --Tobias1984 (talk) 11:55, 30 June 2016 (UTC)


I read a little about whitelisting/blacklisting infoboxes and other ways to include exclude displaying information from Wikidata. Is there any concensus how that that should work? I can think of these possiblities:

1) Local value. No need for Wikidata information:
|genre = Fiction

2) No local value. Display Wikidata information:
|genre =

3) No key given. This could default to Wikidata information or omitting it from this infobox.

4) Blacklist fields (In combination with 3 a blacklist would omit the key from the infobox):
|blacklist = genre

5) Whitelist fields (In combination with 3 a whitelist would show the Wikidata information for this key):
|whitelist = genre

6) Use special strings to exclude Wikidata
|genre = %nowikidata%

7) Use special strings to include Wikidata
|genre = %wikidata%

Any experience from different project would be valuable for this tutorial. How did the local community react to these defaults? --Tobias1984 (talk) 13:40, 30 June 2016 (UTC)

  • Merely for the tutorial, I think that one shouldn't start with infoboxes where this is likely to be an issue. I doubt that on cebwiki there is much debate about this for taxoboxes.
    --- Jura 14:06, 30 June 2016 (UTC)

Upgrading infoboxes and demo infoboxesEdit

One way to enable Wikidata in infoboxes is to re-write the entire infobox in Lua, but that doesn't scale very well and re-uses a lot of code redundantly.

Another approach is to create an alternative to a current infobox which modifies each parameter definition in the infobox to use a standard call to a single Lua module, allowing a value to be fetched from Wikidata. To enable Wikidata-fetching for an article, it is necessary to substitute the alternative infobox for the current one.

A third approach is to replace an existing infobox with one where the parameters have been modified as in the second example. However, this will require a mechanism for enabling the Wikidata-fetching on a per-article basis.

I've left this comment at but perhaps it's worth repeating here to get more eyes on it.

On English Wikipedia we have en:Module:Wikidata and en:Module:WikidataIB as examples of using Lua to get values from Wikidata. Each of them deals with multiple values for a property reasonably well in most cases, particularly when the values represent items that are internally wiki-linked.

The Wikidata module contains calls for use in upgrading infoboxes where the absence of a locally-supplied value causes a value to be fetched from Wikidata ("opt-out").

The WikidataIB module is intended for use in upgrading infoboxes where consensus is that they should only fetch Wikidata once enabled in an article. The operate in conjunction with a whitelist and a blacklist of fields, editable on a per-article basis.

Hope this will help guide the tutorial. --RexxS (talk) 16:54, 30 June 2016 (UTC)

I tried previewing {{Infobox_person/Wikidata}} on w:Barack Obama.
Compared to {{Infobox Biographie2}} on fr:Barack Obama and
{{Infobox - osoba}} on cs:Barack Obama, there still seems work to do.
--- Jura 09:19, 2 July 2016 (UTC)
Do you mean that {{Infobox_person/Wikidata}} doesn't have all the fields enabled yet? Yes, of course - it's a demonstration of fetching Wikidata for fields when no local value is supplied. What other work needs to be done to make a demonstration? How do other language Wikipedias deal with the problem of editors insisting that some infoboxes only fetch Wikidata when specifically enabled in an article? It seems to me that that's where the work is still to be done. --RexxS (talk) 01:43, 10 July 2016 (UTC)

Wikidata infoboxes for main groups of items?Edit

At Wikidata:Statistics/Wikipedia, there are the main groups of articles that can be found in various Wikipedias. These are:

  1. articles about people
  2. articles about taxa
  3. articles about geographic locations

Ideally, for each one there would be an working infobox that could be used in any Wikipedia.
--- Jura 09:19, 2 July 2016 (UTC)

One infobox for people is not common: most of the time a large number of infoboxes exist for persons according to their main occupation. Just proposing one infobox is useless because nobody is interested in that kind of templates. Or you should develop a very complex template able to treat each possible occupation in a different way. Snipre (talk) 12:20, 5 July 2016 (UTC)
French and Czech may be exceptions. In any case, it's better to propose at least one working one than provide people with the cywiki experience mentioned above. ..
--- Jura 12:24, 5 July 2016 (UTC)
I can see value in having a working infobox for each of those common groups that could be used in smaller Wikipedias to help start new articles. For larger Wikipedias, the question is more about how existing infoboxes in existing articles could be upgraded to draw their information from Wikidata. What is needed in those cases is a way of teaching infobox designers how to incorporate Wikidata - and this tutorial can be useful for that. Having a Wikidata-aware example of an infobox from each of those three groups would then be useful to help designers work out how to adapt their existing infoboxes, which might differ significantly in presentation from the example. You can't expect editors who are already accustomed to a particular style of infobox to accept a replacement that doesn't look the same. --RexxS (talk) 02:18, 10 July 2016 (UTC)

ruwiki samples?Edit

There is a request by Putnik at m:Grants:Project/Putnik/Wikidata module‎ to fund i8n of these and store them on I think we should include samples here as well. Not sure if it's going to solve everything (how could it?), but I think it should get us further.
--- Jura 09:18, 6 August 2016 (UTC)

@Jura1: Good idea. This tutorial also needs more work and is not covering the more complex Lua-only infoboxes. --Tobias1984 (talk) 11:03, 6 August 2016 (UTC)


The Extension Capiunto would be a big help for building infoboxes. This extension is on, see Module:T126399, but that was in February 2016. Something stopped the extension, I guess. --Molarus 08:57, 7 August 2016 (UTC)

Wikidata-based infoboxes implemened at Wikivoyage/deEdit

Since several weeks, Wikidata-based infoboxes are implemented at the German Wikivoyage using Lua programming language. The infoboxes are named Quickbars. To have an imagination you can see it working with most of the articles like voy:de:Cottbus. The main Lua code could be found on voy:de:Modul:Wikidata2, voy:de:Modul:Quickbar2 and voy:de:Modul:Quickbar Ort. So you can learn about the big efforts to do to present Wikidata items on the Wikis. To make the usage of Wikidata data more comfortable it is necessary to extend the Wikidata Lua API.

The author, User:DerFussi, made the proposal to present and discuss the ideas and its realization at the WikiCon2016 in Kornwestheim but this proposal was unfortunately denied by the conference organizers. --RolandUnger (talk) 08:38, 19 September 2016 (UTC)

  • Good news. I made Q26932635 for the tourist office and linked it from Q3214#P2872.
    --- Jura 09:55, 19 September 2016 (UTC)

Badge ?Edit

Please see Wikidata:Project_chat#Badge_for_templates_that_can_work_with_Wikidata_only.3F.
--- Jura 09:48, 15 January 2017 (UTC)

Fiwiki examplesEdit

All infobox templates are still old template wikicode and only values are fetched using lua. Wikidata access Lua module is from frwiki.

--Zache (talk) 19:31, 2 August 2017 (UTC)

Wikidata vs local value testsEdit

Maybe this is relevant here too. In Finnish Wikipedia we are using Wikidata values as expected results for the local values in the infoboxes. Basic concept is that if the local value that has been matched to The wikidata value AND it is changed so that it doesn't match anymore then it will trigger the abuse filter rule which will tag or disallow the edit. If local and wikidata values don't match then relevant tracking categories are also added. I wrote a more detailed explanation in the page Wikidata:WikiProject Video games/wikidata value test for template example. --Zache (talk) 19:37, 2 August 2017 (UTC)

Add Databox example as an easy-to-use Lua-only infoboxEdit

TODO: --Tobias1984 (talk) 12:43, 20 May 2018 (UTC)

Coordinates from Wikidata in InfoboxesEdit

Are there any experiences with coordinates P625 (i.e. from headquarters location P159) in Infoboxes? Most Infoboxes have a field for parallel and meridian which is difficult to catch with #invoke:Wikidata. --Newt713 (talk) 06:33, 18 September 2019 (UTC)

{{#invoke:Wikidata|claim|P625|parameter=latitude}} (or parameter=longitude) works for me in dewiki. Did you try this? --MisterSynergy (talk) 08:48, 18 September 2019 (UTC)
Thank you. {{#invoke:Wikidata|claim|P159|qualifier=P625|parameter=latitude}} is working nicely! --Newt713 (talk) 20:41, 18 September 2019 (UTC)

Fetch Units in InfoboxEdit

How can I fetch units from Wikidata like the currency of a budget. I fetch the number like i.e. {{FormatNum|{{#invoke:Wikidata|claim|P2769}}}} but would like to add the currency like $ or €. --Newt713 (talk) 10:27, 19 September 2019 (UTC)

I think this should be similar as in the previous section, but with parameter=unit. There is some helpful documentation about Module:Wikidata at de:Wikipedia:Lua/Modul/Wikidata/de in German language. Not sure whether that helps you... —MisterSynergy (talk) 19:11, 19 September 2019 (UTC)
Okay thank you! This gives me the Wikidata-ID of the Currency. {{#invoke:Wikidata|labelOf|{{#invoke:Wikidata|claim|P2769|parameter=unit}}}} works. Even so I'm not sure this is the most elegant way of doing it? --Newt713 (talk) 20:00, 19 September 2019 (UTC)
Maybe use {{#statements:P2769}} directly? I don't have much experience with Infoboxes, thus I have to guess a lot here as well :-) —MisterSynergy (talk) 20:39, 19 September 2019 (UTC)
Return to the project page "Infobox Tutorial".