Page MenuHomePhabricator

Semantic content blocks
Open, Needs TriagePublic


(This is a very early draft for an RfC, with large parts missing. Shared early so there is a central place for discussing the idea.)

MediaWiki does not offer much of a toolset currently to separate content from presentation (templates help keep the article space mostly clean of presentational information, but are still a mix of content logic, metadata logic and presentation logic, and are also very limited in how much they can influence the way the content gets presented). As a result, editors either have to stick to dull textual information, or create (partly) presentational templates which have mediocre looks, offer a poor development experience, cannot handle device diversity and cannot meaningfully interact with skins. (Infoboxes and navboxes are some typical examples of this.)

Ideally, editors should be able to assign semantics to a block of structured information, and leave the presentation to the skin. ("Skin" in this context could possibly include templates maintained on-wiki, but those templates should have better HTML and CSS tooling, more influence over the resulting layout, and the ability to be "subclassed" per skin and/or device.) This would enable innovative skin features such as the right rail in Winter; limiting or omitting content for more restricted interfaces, such as tiny viewscreens (done on the server side, so performance is not burdened by the sending of unnecessary content and by the need for complex client-side transformations); and straightforward rendering starting from semantic data (instead of wrangling the HTML output designed for desktop) for alternative formats such as PDF exports.

T25796 was a step in this direction (hand over control over a piece of content to the skin, teach skins what to with contents of a certain type), but there should be a more generic and more structured (with key-values instead of a single string input) way of doing this.

Example: the first sentence of a biographical article is usually a good summary of what that article is about, but it contains a long string of data (birth/death place/date, pronunciation, full name) that's relatively unimportant and should not be there in certain contexts. With semantic blocks, one could write something like this:

'''Vincent Willem van Gogh''' {{#block|role=pronunciation|IPA=ˈvɪnsɛnt ˈʋɪləm vɑn ˈɣɔx}}{{#block|role=birth and death|birth=30 March 1853|death=29 July 1890}} was a major [[Post-Impressionist]] painter.

and then the blocks would be processed in different ways in different contexts, resolving to a piece of text for a conventional skin, no text but side-channel data for a skin with a right rail for metadata, and no output at all for mobile.

See also T103624 which is a similar proposal for media.

Event Timeline

Tgr raised the priority of this task from to Needs Triage.
Tgr updated the task description. (Show Details)
Tgr added a project: MediaWiki-General.
Tgr added subscribers: Tgr, Spage.
Tgr updated the task description. (Show Details)
Tgr set Security to None.

This is close enough to the "Making templates semantic" section in my Global templates proposal. I added a link from that page to this task.

Global templates and Semantic templates are distinct, but related projects. Some semantically defined blocks will be useful to all wikis and languages, and so their semantic description should be global as well. And some can be local.