Page MenuHomePhabricator

Create templates wiki to hold global templates and documentation during development and testing
Open, Needs TriagePublic

Description

tldr: Currently there is an extension (https://www.mediawiki.org/wiki/Extension:WikiMirror) allows mirroring a namespace to a different wiki, and allow wiki to fock or override remote pages. This task proposes to create a new wiki templates.wikimedia.org, and mirror that wiki's either Template namespace or a global namespace (TBD) to all Wikimedia wikis via WikiMirror. This will make templates defined there usable in most Wikimedia wikis (unless local wiki has a local version of template).


Full description:

There's a lot of interest in building out a global templates system separate from the Produnto system being set up for Lua modules, along the lines of Tim Starling's MVP proposal. This would require having a single global wiki to hold the actual global template pages and centralize their editing.

(Note I don't think that global templates belong on mediawiki.org, which is more software-documentation-oriented, or meta.wikimedia.org, which has its own community/process documentation and discussion focus, nor on commons.wikimedia.org which is oriented around photos and media; they deserve a distinct wiki which can be home to documentation and localization pages specific to the global templates, keeping search scope clean etc.)

WikiProject Med's community tech team is interested in actually building the global templates MVP over the next few months; what we need from WMF to make this possible is the creation of the global templates wiki and setup of the client side on the other wikis in a fully-testable environment (thus initially on beta cluster), a security review on the extension, and getting the final production templates wiki set up and extension deployed to production wikis once ready.

I recommend creating a beta templates wiki sooner rather than later so that documentation and provisional templates can be built there and hooked up to it in the future:

  • Create new wiki "templateswiki" / "templates.wikimedia.org" / "TemplatesWiki" (provisional name per feedback so far)
    • This should initially be on Beta Cluster only, as templates.wikimedia.beta.wmcloud.org
  • Add a namespace "Global:" on it to hold the global templates distinct from local templates that happen to be there
    • Double-check: are we happy with this namespace name? Or "Global template:"?
  • Invite editors to start hashing out how they'd port templates with localized text segments etc
  • ... -> as we actually build the MVP global templates, start plugging it into the beta wikis on both the templates wiki and the beta wikipedias as client wikis to test with.
  • For beta purposes, consider installing WikiMirror extension pointed at enwiki to make it easy to import live templates from there to work on. If this is a holdup for getting things running, this is optional.

Cf older tasks T52329 (has become Scribunto-specific) and T121470 (from Community Wishlist, may want to merge together with this task).

Event Timeline

Possible duplicate of T121470: Central Global Repository for Templates, Lua modules, and Gadgets, assuming that ticket's implementation plan is also to create a new wiki.

_nod_ it may be worth consolidating and rewriting the proposal on T121470.

Novem_Linguae someone there requested we create a subtask. So here is the subtask of that.

Still kind of lost, even after reviewing the context of T121470, as to why Meta or mediawikiwiki could not be feasible, through just adding a global namespace into either of those wikis and adding global templates to that namespace. Meta, for example, already holds multiple functions that have global effects.

I am quite skeptical for this since additional wiki fragments community.

And if we develop it as an extension, what's needed for short term is not a new Wikimedia production wiki, but a prototype hosted in WMCS or Beta Cluster. I oppose creating a production wiki until (1) The feature is usable in Beta Cluster and (2) The feature passes all reviews to be deployed in production.

invite editors to start hashing out how they'd port templates with localized segments etc

So the way to build global template is not yet stable. It should be better started as a test.

Sure this Wiki could be started as a test wiki, but IMO it should be an independent Wiki. We need to develop a community around this. And we will need to have a dedicated admin pool. Using a namespace in another project and relying on admins from Commons or Meta, which have different priorities, does not make sense. Additionally we will likely need additional software that would not be of use for other projects, to make the templates more seamlessly multilingual.

We have already built an extension called Extension:WikiMirror https://www.mediawiki.org/wiki/Extension:WikiMirror which mirrors all templates and modules from EN WP into MDWiki. And these templates then work seamlessly within MDWiki.org (both within local articles and within other mirrored templates). One can fork any template and bring it locally with a click of a button, and if one wants to go back to the mirrored templates it takes a couple of more clicks. It can be easily adapted to pull templates from a central wiki into any mediawiki install so we will be able to begin further development.

I am happy to demo how our current system works for those who may be interested.

This provides reason that we need a new project. But another part of my concern is we do not need a production project currently until a Beta Cluster equivalent is set up and functional.

create new wiki "globalwiki" / "GlobalWiki" (are we happy with this name or need something else?)

That's a rather bad name. It should obviously be called "Templates Wiki" (or "Wikitemplates")/templateswiki/templates.wikimedia.org.

This provides reason that we need a new project. But another part of my concern is we do not need a production project currently until a Beta Cluster equivalent is set up and functional.

Isn't beta cluster supposed to be a nearly identical mirror of production? Is there any precedent for creating wikis on beta cluster that are not already created in production? (I suspect not, but could be wrong.)

@Bugreporter Thanks, reading about the Beta Cluster and it looks like that will work as a testing environment. We will give it a try.
@NguoiDungKhongDinhDanh Yes I like templateswiki or templates.wikimedia.org

globalwiki

This name may come from the https://meta.wikimedia.org/wiki/Global-Wiki proposal, but many features proposed there is or will be worked in different ways (global user pages in Meta, global modules in GitLab via Produnto and global gadgets likely also in GitLab).

many features proposed there is or will be work in different ways (global user pages in Meta, global modules in GitLab via Produnto and global gadgets likely also in GitLab).

Don't let perfect be the enemy of good. I'd say my preference for the templateswiki name outweights that "inclusivity" concern.

bvibber renamed this task from Create global wiki to hold global templates to Create templates wiki to hold global templates and documentation during development and testing.Oct 5 2026, 12:45 AM
bvibber updated the task description. (Show Details)

I've retooled the task description in response to above discussion:

  • globalwiki -> templates wiki
  • Recommend starting with a beta cluster installation
  • Set up the wiki now to start documenting and experimenting, then enable the extension as it gets into a testable state
    • This means we can test both the central part and the client wikis on beta cluster without interfering with production wikis
  • Note we're interested in setting up WikiMirror extension to make it easy to import templates from enwiki; may need to specify the exact recommended config. If this causes a holdup, we'd rather proceed with the other setup without it though.

what we need from WMF to make this possible is ... a security review on the extension

More than this is needed nowadays to get a new extension deployed to wikimedia production. Needs a wmf team to sponsor it. Extension:Adiutor got blocked on this a year or two ago.

Yes, getting a WMF team to sponsor, is definitely on the roadmap. First want to get a cleaner/ clearer example of how things will work to pitch to both them and our communities as a potential solution,

Add a namespace "Global:" on it to hold the global templates distinct from local templates that happen to be there

Do we actually need a new namespace (and a new syntax like {{#global:}}) at all, though?

For example, let's say {{Ping}} was globalized. If we used two different namespaces/syntaxes, {{ping|Example}} would not work as it is on Wikitemplates itself. Instead, people would have to remember which are global and which local.

A better solution would be to keep them in the same standard Template namespace, and set up an approval system that allows admins (plus maybe a template editor group) to:

  • Configure if a template is local or global
  • Opt wikis out of a global template

(Templates are safe by design, so perhaps even private and fishbowl (non-SUL) wikis can be opted in by default.)

setting up WikiMirror extension to make it easy to import templates from enwiki

I don't believe this is the proper approach. We certainly does not need to mirror (i.e. keep in sync, instead to forking) any pages from enwiki to this global template wiki; what is useful is the inverse (mirror global templates to local wiki), but it has its own caveat. (This would require WikiMirror be installed in client wiki, not global template wiki.)

Update: WikiMirror can also be installed in global template wiki, but its goal would be mirror pages from itself (i.e. mirror pages from "Global" namespace to template namespace so it can be used as templates locally).

what we need from WMF to make this possible is ... a security review on the extension

More than this is needed nowadays to get a new extension deployed to wikimedia production. Needs a wmf team to sponsor it. Extension:Adiutor got blocked on this a year or two ago.

Many extensions are managed by WMDE without involving a WMF team. I believe WMF should maintain a list of recognized affiliates who are able to take care with production extensions by itself, and WikiProjectMed can be one. (In my vision, many extensions can be managed by such kind of bodies, and this is why I believe disbanding of CommTech is not that important.)

For example, let's say {{Ping}} was globalized. If we used two different namespaces/syntaxes, {{ping|Example}} would not work as it is on Wikitemplates itself. Instead, people would have to remember which are global and which local.

There are certainly some templates only useful in the global template wiki itself. Instead we can have a global namespace and make global template wiki its own client so any global templates can also be used locally.

Using the template space itself might also work to build / store global templates. Having a few extra templates available globally that are not particularly useful to others is not really a big deal. Unless I am missing edge cases.

Would be useful to have a template "metadata space" though, as would be good to split that material out from the templates themselves.

Also what is the process for getting these new beta clusters wikis? Ie is there a specific individual who brings them into existence at the foundation or within the community?

I would have thought the best way for this to work would be similar to system messages. That is, the local template to be used unless it didn't exist, in which case the global template would be used instead. That means that local wikis could create local overrides if they wanted to.

One thing I'm not clear on is how centrally-set templates can interact with centrally-set Lua modules if they're kept in different places.

Per "local template to be used unless it didn't exist , in which case the global template would be used instead. That means that local wikis could create local overrides if they wanted to." Yes that is currently exactly how WikiMirror works. Happy to demo WikiMirror for those interested.

Initially we plan to bring some Lua modules onto this Wiki for testing purposes. Have a discussion with Tim Starling in a week or two about how this setup should mesh with gitlab/produncto. May need a similar mirroring infrastructure.

I would have thought the best way for this to work would be similar to system messages. That is, the local template to be used unless it didn't exist, in which case the global template would be used instead. That means that local wikis could create local overrides if they wanted to.

This is just T91162: RFC: Shadow namespaces.

Per "local template to be used unless it didn't exist , in which case the global template would be used instead. That means that local wikis could create local overrides if they wanted to." Yes that is currently exactly how WikiMirror works. Happy to demo WikiMirror for those interested.

Initially we plan to bring some Lua modules onto this Wiki for testing purposes. Have a discussion with Tim Starling in a week or two about how this setup should mesh with gitlab/produncto. May need a similar mirroring infrastructure.

Another thing to consider is 3rd party wiki may do not want Produnto, instead it may want to just mirror both template and module namespace from wiki A to wiki B. And templates in wiki A (potentially using modules) should work out of box in wiki B.

In Wikimedia until T436322: Allow deployed packages be used without a proxy module is solved we still needs a local module (for now it must be created beforehand), so mirroring modules is still potentially useful.

The issue of WikiMirror-Produnto integration is we have no way to enforce same version of same package be deployed globally. In fact it is currently impossible to deploy something globally - T436328: Allow a package be deployed globally.

Hello all, I wanted to flag this write up -- https://www.mediawiki.org/wiki/MediaWiki_Product_Insights/Artifacts/Cross-Wiki_Code_Collaboration -- which was the motivation for us (Content Platform Team and Tim Starling) to start experimenting with Produnto, which at this point is already enabled on the following wikis: testwiki, mediawiki.org, and a small set of Indian language wikis as part of a small pilot so we gain experience in a small controlled environment, fix problems, and make changes before moving ahead with it. We have deliberately kept it all low key for that reason and have not made any major announcements yet. Eventually, this approach can scale to gadgets and templates, but supporting those will need a bunch of additional work.

We've have deliberately chosen the Produnto approach as our initial foray into the cross-wiki code sharing requirement. It provides useful functionality to support three distinct user groups: (a) individual module developers who wish to use standard developer tooling for Lua code while enabling wiki-integrated testing. (b) as a shared code repository for Wikimedia wikis to develop shared code libraries which can be imported and used by individual wikis however they wish -- this also helps other larger wiki farms (c) sharing between mediawiki wikis / and wikifarms via the git clone approach. So, this allows code collaboration in two ways: (a) standard git collaboration across wikifarms (b) shared produnto database within a wikifarm. So, given this two-level code collaboration strategy, you can clone (and hence mirror) standard Lua libraries and adapt them for use in a wiki context. If you just copied Lua code from a git repo (wither standard Lua libraries, OR from other mediawiki wikis or wiki farms) into a shared global wiki, you will now need to build custom mirroring solutions and solve the problem of syncing. With git, you get that for free.

There is a very clear and deliberate reason why we picked Lua module code to start this exploration. Lua code is code that is most amenable to the code library approach because it is based off a real programming language. And, you get code sharing at multiple levels, it is not an all-or-nothing approach. A wiki can choose to import a shared library that forms the scaffold of some larger functionality in a local wiki-specific code module.

Gadgets are also code, in our discussions to expand Produnto to gadgets, we've come to realize that as written today, gadgets can be long single-file monoliths and users have built dependency mechanisms through documentation at this point, and @tstarling strongly recommended that code sharing for gadgets should look at improving gadget functionality alongwith expanding code sharing there. Otherwise, the full benefits and features of modularity and code sharing will be lost. But, this is a conversation.

And, templates are harder for some of the same reason as gadgets. Templates should ideally be a last-mile solution that are used as a presentation layer that leverages modules underneath because while templating with parser functions is turing-complete and you can write and build whatever you want, the result is not pretty and definitely harder to maintain. Without scoping and modularity features, template sharing is going to be lot more messier and my speculation is that it is lot more likely to be an all-or-nothing affair from the top-level template all the way down to its building block templates. And, this means once these templates are shared, it is much trickier and harder to tweak them. There is also the issue of updating templates that are globally used and the load they have on the production infrastructure in terms of filtering down all the changes to all the pages on all wikis that use them. That is a non-significant production load consideration (and we have had more than one production load incident in the recent past with updates to a popular template/module on a *single* wiki). With Parsoid, we are currently working on selective update solutions to mitigate that, but for the reasons shared above, templates will likely run into this more than modules. With Produnto, local wikis get their own local copies of code. And, they can choose to update their wikis on their own staggered schedules (and/or we can build some lag mechanisms in Produnto if necessary) -- i.e. code is shared, it is not forced to be global. So, we should think through some of these other implications as well.

That said, Produnto can support templates as well (and will need some more features to be built), but we wanted to hold off on that while we get the module experiment underway and understand what functionality is helpful and what is missing. And, all the two-level code sharing functionality comes for free with Produnto.

For all these reasons, I think it makes sense to go bottom up from Lua code up to templates. A global code wiki and Produnto shared code database will be working at cross-purposes. I don't question the ingenuity of the wiki community in making things work with the technical tools they have (that has been the impressive history of the wikimedia wikis), but I nevertheless feel that we should let the Produnto experiment play out for a bit - it just got kicked off and @MSantos had his very initial workshop with the indic wikis which only was a basic introduction and he is going to push that ahead with those indic wikis.

@bvibber let me know if you want to get on a call to chat more.

I believe using Produnto for templates is a bad idea:

  • Wiki can have much more templates than modules (consider navboxes), and for now Produnto require explicit opt-in (i.e. deployment) by privileged users (by default sysops). It is not a scalable workflow if we need sysop approval for each usage of template.
    • A more extreme case is template that is conceptually wiki-agnostic but used in a niche number of pages, e.g. RDT (rail diagram templates) can be just used in one single article per-wiki.
  • A second issue is some template contains frequently updated content. The design of Produnto is every new version need to be manually deployed to each wiki which is not suitable for e.g. Olympics medal table (in this case Commons tabular data would be a better source of truth, but we also have usecases not solvable by Commons nor Wikidata).
  • Third issue is templates are just wikitext, they are native to MediaWiki. So it is not really a good practice to develop templates via GitLab since it loses the environment of template development. In particular many templates needs a full MediaWiki environment to work - some may depends on certain extensions like ParserFunctions.
  • A second issue is some template contains frequently updated content. The design of Produnto is every new version need to be manually deployed to each wiki which is not suitable for e.g. Olympics medal table

This comment seems to be conflating template code - and template content.

More generally, before we settle on a technical solution, I think it would be useful to sketch out - at a very high level, but in more detail than "share templates" - what it is we want to be able to do with that technology. Should that be done here, on a wiki, or somewhere else?

I for one dislike writing any kind of HTML in Lua.

Lua, minimal as it was originally intended to be, is not and has never meant to be a template language. Granted, modules are useful for generation, what with infobox fields and all, but they don't provide a declarative approach to HTML the way wikitext does. For an example, here's how I generate a SVG clock in Lua (I don't have a more HTML-y example, but it's the same mw.html library):

local minute_marker = mw.html.create('circle')
	:attr('id', 'minute-marker')
	:attr({ cx = '0', cy = '87', r = '2.2', fill = '#000' })
local minute_hand = mw.html.create('line')
	:attr({ x1 = '0', y1 = '-95', x2 = '0', y2 = '0', stroke = '#000', ['stroke-width'] = '2.8' })
	:attr('transform', ('rotate(%s)'):format(minute_hand_angle))

For comparison, here's how I would write the same thing in Vue:

<circle
	id="minute-marker"
	cx="0" cy="87" r="2.2" fill="#000"
/>
<line
	x1="0" y1="-95" x2="0" y2="0" stroke="#000" stroke-width="2.8"
	:transform="`rotate(${minuteHandAngle})`"
/>

...and in a hypothetical dialect of wikitext:

<circle
	id="minute-marker"
	cx="0" cy="87" r="2.2" fill="#000"
/>
<line
	x1="0" y1="-95" x2="0" y2="0" stroke="#000" stroke-width="2.8"
	transform="rotate({{{minute hand angle|}}})"
/>

The first is harder to read and much more cumbersome to write. Did you know that non-identifier table keys not only have to be quoted, but also bracketed? Did you know that, to make a method call on a string literal, that string needs to be parenthesized first? Did you know that, if you used %i instead of %s and the user-provided argument you unwittingly pass on to string.format() was an empty string, you'd get a big red Lua error incomprehensible to most users?

In simple cases, wikitext is no doubt the preferred language over Lua.

I for one dislike writing any kind of HTML in Lua.

...

In simple cases, wikitext is no doubt the preferred language over Lua.

I am not and I don't think anyone else is proposing that we should not use wikitext templates and only use Lua. There will be different preferences and tastes around what the boundary ought to be between Lua modules and wikitext templates, but I think that is tangential to this discussion.

I am not and I don't think anyone else is proposing that we should not use wikitext templates and only use Lua.

Sorry, I skipped several steps there. Let me try again.

That said, Produnto can support templates as well

As I understand it, this proposal means that global wikitext templates will be implemented using Produnto, which is to say that they will be stored as .wikitext files on GitLab instead of template pages on Wikitemplates.

As Bugreporter has said, the native environment of MediaWiki is essential to the development of wikitext templates. Other platforms might not even support syntax highlighting for wikitext, let alone the new suite of features that have been coming to MediaWiki-extensions-CodeMirror recently. To me, it's either wikitext on MediaWiki, or no wikitext at all. If Produnto were to support templates, it should not make us write wikitext elsewhere.

Sure we would be happy to meet and discuss. I was under the impression that there were no plans for Produnto to handle templates, just modules. I would still be interested in building out the solution we have on the Beta cluster as it is mostly already done/functional on MDWiki. Then we can compare the two approaches more easily. But yes being able to write / edit templates within mediawiki using Wikitext is key for me as a not very technical person.

Right, Produnto use for templates is not under active consideration now, but there is nothing inherently in that extension that prevents that (it will need work, and I don't want to commit anyone to work on that unilaterally, and there are product considerations around it as some editors above chiming in illustrate) - but yes, the current focus of Produnto is definitely only Lua modules. At the very least, I want to make sure that work on Produnto and work on this don't happen at cross purposes. Tim is out on vacation, so once he is back, we can find a time to talk.

@ssastry Agree we want to avoid working at cross purposes. Yes lets work on scheduling a meeting in about 10 days. Would like to demo you what we have on MDWiki, and how we imagine one potential solution. And would love to get a demo of Produnto. Finding a time that works might be a bit tough with folks all over but I am sure we can manage.

In simple cases, wikitext is no doubt the preferred language over Lua.

But in pre-Lua era a number of templates are monsters - see https://meta.wikimedia.org/w/index.php?title=Template:Infobox&action=edit&oldid=3506389 (which is just a simple one; {{Convert}} then uses hundreds of subtemplates to work.)

And this is why we have Scribunto - https://www.mediawiki.org/wiki/Requests_for_comment/Scripting

  • A second issue is some template contains frequently updated content. The design of Produnto is every new version need to be manually deployed to each wiki which is not suitable for e.g. Olympics medal table

This comment seems to be conflating template code - and template content.

More generally, before we settle on a technical solution, I think it would be useful to sketch out - at a very high level, but in more detail than "share templates" - what it is we want to be able to do with that technology. Should that be done here, on a wiki, or somewhere else?

In my vision we should able to share templates with content (e.g. navboxes), by replace each links with some sorts of "Wikidata magic links". An obvious one is list of US presidents.

BTW: a navbox for US presidents is a navbox for a "conceptally meaningful" list (i.e. a list that can reconstructed from a different source of truth, such as querying Wikidata, or simply parsing table in Wikipedia articles), in which case global templates is in my opinion not the best solution; T332484 is my proposed solution. By comparison, the {{Russo-Ukrainian War}} does not have any "conceptal meaning" other than being related to a specific topic (i.e. you can not reconstruct the list of items if the original template is lost), and may be a better example for global templates.

Note WikiMirror is not yet ready to be deployed to production wikis. There are several issues to solve:

  • Since local wiki can override global templates including high-risk ones, the permission to override global templates must be restricted.
  • A more tricky case is global templates are created after local ones - e.g. we created a global template called {{magic link}} (see previous comment) then local wikis with a local template with such name can not use this global template, unless (1) the local template is renamed without leaving redirect, which is quite a breaking change for widely-used templates; or (2) we introduce a new syntax to explicitly transcluding global template (and we need a solution if modules want to get the content of global templates via Lua).
  • A even more tricky cases is a global template uses a different template. Then the names should resolve to global template only or local first?
    • Local first, e.g. If a navbox uses a new global template {{magic link}}, then the navbox will suddenly stop working on wikis with an existing template with such name.
    • Global only, which is how GlobalUserPage works - means local wiki can not "plug-in" global template. Allowing "plug-in" allow local communities to customize global templates without forking the entire template locally. A simple example is a template can be a wrapper of {{delete}}, but different wikis implements {{delete}} differently.

WikiMirror supports caching and if cache is enabled viewing uncached remoted pages requires login (https://github.com/SkizNet/mediawiki-WikiMirror/commit/42eb8363f303165195acb16e0902f30d0684482e). The purpose is to prevent (search engine or AI) crawlers from making huge number of proxy requests to Wikimedia wikis; but such hack is not desireable in Wikimedia projects. Wikimedia may want a different way to prevent crawling of large number of mirrored pages.

@Bugreporter
Per "Since local wiki can override global templates including high-risk ones, the permission to override global templates must be restricted." On MDWiki we have an "importer" user group. A global template must be forked before it can be overwritten. Thus a mechanism to prevent overriding global templates already exists.

For wikis who wants to go from a local template to a global one, they will need to delete the local one (or move it) and then hit the "mirror" button. This then pulls the global template into that name. Not sure why we would need / want both a global and a local template of the exact same name? Yes their might be edge cases where a template needs renaming. We encounter the same issue with images (if a local image and a Commons image has the same name).

Local templates take precedence over global ones. This has not resulted in significant issues on MDWiki since we launched it a few years back. One can have one part of a nested template globally and another part of a nested template locally though. And the global template on a wiki, can use the subtemplates that exists locally.

With respect to viewing uncached remote pages, for sure. We will be making a bunch of changes to this extension to make it more specific to WMF wikis, if we get support to move ahead with this idea.