Logo di Wikimedia Page Styling

Wikimedia Page Styling

Community
fuzheado
wikimedia-page-styling

Use TemplateStyles to load custom CSS on wiki pages, then build responsive grid/flexbox layouts, card-based tile systems, color themes, button systems, and full visual design systems — transforming plain MediaWiki pages into rich, interactive-looking interfaces

Panoramica

Pubblicato dafuzheado
RepositoryWikipedia-AI-Skills
Nome della skillwikimedia-page-styling
Stelle
27
Fork
10
File inclusi
8
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • File inclusi: 8

    Script, template e riferimenti che il modello può leggere mentre lavora. I file sono di sola lettura e non vengono mai eseguiti.

  • Open source

    Pubblicata da fuzheado su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Wikimedia Page Styling in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/fuzheado/Wikipedia-AI-Skills/tree/main/.claude/skills/wikimedia-page-styling
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/fuzheado/Wikipedia-AI-Skills.git /tmp/Wikipedia-AI-Skills
mkdir -p .claude/skills
cp -r /tmp/Wikipedia-AI-Skills/.claude/skills/wikimedia-page-styling .claude/skills/wikimedia-page-styling
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Wikimedia Page Styling in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Wikimedia Page Styling non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Wikimedia Page Styling non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

⚠️ User-Agent required: The API examples below hit Wikimedia endpoints. All requests must include a descriptive User-Agent header. See the wikimedia-api-access skill for the correct format.

📖 Prerequisites: For general template syntax and parser functions, see wikipedia-templates. For navigating subpage hierarchies and building menu navigation, see mediawiki-page-navigation. For the Translate extension and multilingual content, see mediawiki-translate-extension.


Table of Contents

  1. What TemplateStyles Is
  2. How TemplateStyles Works
  3. Creating a CSS Template
  4. Allowed CSS Properties (The Sanitizer)
  5. CSS Grid Layouts
  6. Flexbox Layouts
  7. Card / Tile Design Patterns
  8. Color Theme System
  9. Button Design System
  10. Typography
  11. Responsive Breakpoints
  12. Skin Targeting (Vector / Minerva)
  13. Image Positioning & Object-Fit
  14. Hover Overlays and Transitions
  15. Lua + TemplateStyles Integration
  16. Anti-Abuse Features and Scoping
  17. Cascading Order & Specificity
  18. Debugging TemplateStyles
  19. Reference Links

What TemplateStyles Is

TemplateStyles is a MediaWiki extension (available since MW 1.31, 2018) that allows templates to ship their own CSS without needing site-wide stylesheet edits (MediaWiki:Common.css). It is the single most important feature for creating visually rich wiki pages.

Before TemplateStyles: All custom CSS had to go in MediaWiki:Common.css, which required interface-admin rights and affected every page on the wiki. Template authors could only use inline styles (style="..."), which are repetitive, unmaintainable, and cannot use media queries.

After TemplateStyles: Any template can load its own CSS from any page in the Template namespace ending in .css:

wikitext
<templatestyles src="AvoinGLAM/style.css" />

This CSS only applies to the page where the template is transcluded — it does not leak to other pages.

What TemplateStyles Enables

CapabilityWithout TemplateStylesWith TemplateStyles
Custom fonts (e.g. Montserrat)Impossible (can't ship font assets)✅ Declare in CSS
CSS Grid layoutsInline style on every element✅ Full CSS Grid
Responsive breakpointsImpossible✅ @media queries
Hover effectsInline onmouseover (not possible in wikitext)✅ :hover pseudo-classes
Color themes (.bluebox, .whitebox)Manual on every element✅ Class-based theming
Layout classes (.grid, .boxes)Impossible✅ Reusable CSS classes
Mobile/desktop adaptivityImpossible✅ Responsive design

How TemplateStyles Works

Basic Syntax

wikitext
<templatestyles src="YourTemplate/style.css" />

The src parameter is a page title in the Template namespace (NS 10). The page must end in .css. You can omit the Template: prefix:

wikitext
<!-- These are equivalent: -->
<templatestyles src="AvoinGLAM/style.css" />
<templatestyles src="Template:AvoinGLAM/style.css" />

Placement

Place <templatestyles> near the top of your template, before any HTML that uses the styles:

wikitext
<templatestyles src="Project/colors.css" />
<div class="project-box">...</div>

Multiple Stylesheets

You can load multiple stylesheets — they cascade in order:

wikitext
<templatestyles src="Project/colors.css" />
<templatestyles src="Project/layout.css" />
<templatestyles src="Project/buttons.css" />

Loading from a Template Call

A template can let its caller specify an additional stylesheet:

wikitext
{{#if: {{{style|}}}|<templatestyles src="{{{style|}}}" />}}

What Gets Loaded

TemplateStyles generates a <link rel="stylesheet"> element in the page <head> with a randomized, unique URL that includes a hash of the CSS content for cache busting:

html
<link rel="stylesheet" href="/w/load.php?lang=en&amp;modules=ext.templatestyles;ext.templatestyles.assets&amp;skin=vector&amp;target=AvoinGLAM/style.css&amp;*">

This means changes to the CSS template are reflected near-instantly (subject to CDN cache).


Creating a CSS Template

Step 1: Create the Page

Create a page at Template:YourProject/style.css with any standard CSS:

css
/* Template:YourProject/style.css */
.my-box {
    background: #f1f4f6;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1rem 0;
}

.my-box h3 {
    font-family: "Montserrat", sans-serif;
    font-weight: bold;
    font-size: 1.4rem;
    margin-top: 0;
}

.my-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

Step 2: Create a Template that Loads It

wikitext
<templatestyles src="YourProject/style.css" />
<div class="my-grid">
  <div class="my-box">
    <h3>Card title</h3>
    <p>Card content here.</p>
  </div>
</div>

Step 3: Create a Wrapper Template for Reuse

wikitext
<!-- Template:YourProject/Box -->
<templatestyles src="YourProject/style.css" />
{{#tag:div
|{{#if:{{{title|}}}|<h3>{{{title|}}}</h3>}}
{{{content|}}}
|class=my-box
}}

Key insight: TemplateStyles is loaded every time the template is transcluded, but it's deduplicated per page — the CSS is only fetched once regardless of how many times the template appears.

Naming Conventions

ConventionExamplePurpose
Project/style.cssAvoinGLAM/style.cssMain stylesheet for a project
Project/colors.cssGLAM/colors.cssColor variables/themes
Project/layout.cssGLAM/layout.cssGrid and flexbox rules
Project/buttons.cssGLAM/buttons.cssButton component styles

Allowed CSS Properties (The Sanitizer)

TemplateStyles sanitizes CSS for security — only certain CSS properties and values are allowed. This prevents CSS-based attacks (data exfiltration via background-image: url(...), XSS via expression(), etc.).

Allowed Properties (Complete List)

The sanitizer allows most common layout, typography, and visual properties. Key categories:

CategoryAllowed Properties
Box modelwidth, height, min-width, max-width, min-height, max-height, padding (and -top, -right, -bottom, -left), margin (and directional variants), box-sizing
Display & layoutdisplay, flex, flex-direction, flex-wrap, flex-flow, flex-grow, flex-shrink, flex-basis, grid, grid-template (columns, rows, areas), grid-column, grid-row, grid-area, grid-gap, gap, order, align-items, align-content, align-self, justify-items, justify-content, justify-self, place-items, place-content, place-self
Positioningposition, top, right, bottom, left, overflow, overflow-x, overflow-y, z-index, float, clear
Typographyfont, font-family, font-size, font-weight, font-style, font-variant, line-height, text-align, text-decoration, text-transform, text-overflow, text-shadow, letter-spacing, word-spacing, white-space, word-break, overflow-wrap, hyphens, direction, unicode-bidi, column-count, column-gap, column-width, columns
Color & backgroundcolor, background, background-color, background-image (⚠️ restricted — see below), background-repeat, background-size, background-position, background-attachment, background-clip, background-origin, opacity
Border & outlineborder, border-collapse, border-color, border-style, border-width, border-radius (and directional variants), outline, outline-color, outline-style, outline-width
Visual effectsbox-shadow, filter, backdrop-filter, transform, transition, transition-property, transition-duration, transition-timing-function, transition-delay, animation, animation-name, animation-duration, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, animation-fill-mode, animation-play-state
Listslist-style, list-style-type, list-style-image, list-style-position
Tablestable-layout, empty-cells, caption-side, vertical-align
Contentcontent, counter-increment, counter-reset, quotes
UIcursor, visibility, clip, clip-path, pointer-events, resize, user-select, caret-color

⚠️ Restricted Properties

PropertyRestriction
background-imageOnly linear-gradient(), radial-gradient(), repeating-linear-gradient(), repeating-radial-gradient(), conic-gradient(), repeating-conic-gradient() — no url() for external images or data: URIs
font-familyOnly generic families (sans-serif, serif, monospace, cursive, fantasy, system-ui) and locally-loaded web fonts via @font-face (must be hosted on Wikimedia servers)
@font-faceAllowed but the src URL must point to a Wikimedia-hosted file (Commons or extension)
filterAll filter functions allowed except filter: url() (external references)
clip-pathAll values allowed except clip-path: url()
cursorOnly standard CSS keywords — no custom url() cursors

CSS At-Rules Allowed

At-ruleAllowed?Notes
@media✅ YesAll media queries (screen, print, min-width, max-width, prefers-color-scheme, etc.)
@supports✅ YesFeature queries
@font-face✅ YesFont URLs must be Wikimedia-hosted
@keyframes✅ YesFor CSS animations
@page✅ NoNot supported
@import❌ NoUse separate <templatestyles> tags instead
@namespace❌ NoNot supported

Checking the Sanitizer

To see the exact allowlist for your wiki, inspect the TemplateStyles source: https://gitlab.wikimedia.org/repos/mediawiki/extensions/TemplateStyles/-/blob/master/src/TemplateStylesMatcherFactory.php

⚠️ There is no action=templatestyles API module — TemplateStyles validates CSS via the sanitized-css content model at save time, not through a dedicated endpoint. To validate a stylesheet programmatically, edit a sandbox page with contentmodel=sanitized-css and check for API errors (see "Validating a CSS File" below).


CSS Grid Layouts

CSS Grid is the foundation of the tile/card layout seen on AvoinGLAM pages.

Basic Grid Container

css
.grid {
    display: grid;
    gap: 1.5rem;
    margin: 1.5rem 0;
    grid-template-columns: repeat(auto-fit, minmax(150px, 219px));
}

This creates a responsive grid where:

  • Each column is between 150px (minimum) and 219px (maximum)
  • auto-fit creates as many columns as fit in the viewport
  • Items auto-wrap to new rows as the viewport narrows
  • Gap between items is 1.5rem

Grid Variants

css
/* Two-column grid for wider content */
.grid-wide {
    display: grid;
    gap: 2rem;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* Three-column grid for dense layouts */
.grid-dense {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(3, 1fr);
}

/* Mixed — first item spans full width */
.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}
.blog-grid > div:first-child {
    grid-column: 1 / -1;  /* Spans all columns */
}
.blog-grid > div:last-child {
    display: none;         /* Hides a sentinel/listeria element */
}

Using Grid in Wikitext

wikitext
<div class="grid">
{{Card|title=Item 1|...}}
{{Card|title=Item 2|...}}
{{Card|title=Item 3|...}}
</div>

CSS Grid + #tag pattern (for template authors who prefer parser functions):

wikitext
{{#tag:div
|{{Card|title=Item 1}}
{{Card|title=Item 2}}
|class=grid
}}

The "Listeria" Pattern

Many grid templates hide the last child div — this works with API-driven listers that emit a trailing sentinel:

css
.grid.listeria > div:last-child {
    display: none;
}

Flexbox Layouts

Flexbox is used for navigation bars, button groups, horizontal metadata rows, and alignment tasks.

Horizontal Menu Bar

css
.menu {
    margin: 0 0 1rem 0;
    font-family: "Montserrat", sans-serif;
}
.menu ul {
    display: flex;
    list-style: none;
    margin: 0;
}
.menu ul li {
    font-weight: bold;
    padding: 1rem 0;
    margin-right: 1.5rem;
    margin-bottom: 0;
    color: black;
    transition: 0.3s;
}
.menu ul li:hover {
    box-shadow: inset 0 -2px 0 #0E65C0;
}
.menu ul li a {
    text-decoration: none;
    color: black;
}

Flexible Box Groups

css
.boxes {
    display: flex;
    flex-wrap: wrap;
    column-gap: 1.5rem;
    row-gap: 1.5rem;
    margin: 2rem 0;
}

Horizontal Metadata Rows

css
.logrow {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    column-gap: 0.5em;
}

.someicons {
    display: flex;
    gap: 0.4em;
    flex-flow: wrap;
}

.inventorydata {
    display: flex;
    gap: 2em;
    margin: 1em 0 2em;
}
.inventorydata div {
    flex: 1 1 50%;
}

Alignment Helpers

css
.bi {
    display: flex;
    gap: 1.5em;
    align-items: center;
}

.logcontent {
    display: flex;
    flex-direction: row;
    gap: 1em;
    align-items: flex-start;
}

Card / Tile Design Patterns

The "card" or "tile" is the fundamental building block of rich Meta pages.

Small Box (Tile) Pattern

This is the pattern used in the {{Wiki Loves Living Heritage/Box}} template with color=smallbox:

css
.smallbox {
    padding: 0;
    flex: 1 1 200px;
    min-width: 150px;
    max-width: 300px;
}

.smallbox img {
    border-radius: 8px;
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.smallbox h3 {
    line-height: 1.2em;
    font-size: 1.3em;
    margin-top: 0.6em;
    margin-bottom: 0;
}

Generic Box Pattern

css
.box {
    border-radius: 8px;
    padding: 1.5rem;
}

Box Sizes

css
.quarter {
    flex: 1 1 26%;
    min-width: 250px;
}

.third {
    min-width: 200px;
    max-width: 300px;
    padding: 0;
    flex: 1 1 240px;
}

.half {
    flex: 1 1 40%;
    min-width: 250px;
}

.full {
    flex: 1 1 100%;
    flex-direction: row;
    display: flex;
    gap: 1em;
}

Image-Containing Box

css
.boximg {
    position: relative;
    margin-bottom: 1em;
}

.boximg img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
}

Content Box Layout

css
.blocks {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
}

.blocks p {
    margin: 0.5em 0 0 0;
}

Color Theme System

A color theme system lets pages switch between visual themes by applying a CSS class to a container.

Theme Classes

css
/* Blue theme — for primary/hero content */
.bluebox {
    background: #0E65C0;
    color: white;
}

.bluebox h2, .bluebox h3, .bluebox h4 {
    color: white;
}

/* White/light theme — for secondary content */
.whitebox {
    background: #F1F4F6;
}

/* Alert / notice theme */
.alertbox {
    background: #f8eb79;
}

/* Colored columns for tables/programs */
.col1 { background: #f6b264; }
.col2 { background: #bb5e2d; }
.col3 { background: #b6d0c0; }
.col4 { background: #25a3ac; }
.col5 { background: #045a70; }
.col6 { background: #e98036; }
.col7 { background: #f0d4aa; }
.col8 { background: #4eacb7; }

Using Themes in a Template

wikitext
{{#tag:div
|content
|class=box {{{color|whitebox}}} {{{size|half}}}
}}

The caller picks a color:

wikitext
{{Box|color=bluebox|title=Welcome|...}}
{{Box|color=whitebox|title=Details|...}}

Decorative Logo Backgrounds

Randomized color backgrounds for visual variety (via a #switch in the template):

wikitext
{{#switch: {{#expr: {{#time: xNU}} mod 11 }}
 | 0 = #71D1B3
 | 1 = #970302
 | 2 = #E679A6
 | 3 = #EE8019
 | 4 = #F0BC00
 | 5 = #5748B5
 ...
}}

Applied as background style on a logo container.


Button Design System

Buttons use pill-shaped (border-radius: 2rem) design with outline hover states.

Base Button

css
.btn {
    padding: 0.7rem 1.3rem;
    border-radius: 2rem;
    margin-top: 1rem;
    font-weight: bold;
    display: inline-block;
    font-family: 'Montserrat', sans-serif;
    white-space: nowrap;
}

/* Compact variant */
.tight {
    padding: 0.2rem 0.6rem;
    border-radius: 2rem;
    margin: 0.3em 0.1em;
    font-size: 0.9em;
}

Button Color Variants

css
/* Blue box → white button */
.bluebox .btn, .whitebtn {
    color: #0E65C0;
    background: white;
}

/* White box → blue button */
.whitebox .btn, .bluebtn, .negbtn:hover {
    color: white;
    background: #0E65C0;
}

Button Hover States (Outline Style)

css
/* Blue box — hover outline on white */
.bluebox .btn:hover, .whitebtn:hover {
    background: none;
    outline: 2px solid white;
    outline-offset: -2px;
}

/* White box — hover outline on blue */
.whitebox .btn:hover, .negbtn, .bluebtn:hover {
    background: none;
    outline: 2px solid #0E65C0;
    outline-offset: -2px;
    color: #0E65C0;
}

Button Link Colors

css
.bluebox .btn a, .whitebtn a {
    color: #0E65C0;
    text-decoration: none;
}

.whitebox .btn a, .bluebtn a {
    color: white;
    text-decoration: none;
}

Using Buttons in a Template

wikitext
{{#tag:div
| {{{linktitle|}}}
|class=btn {{{btnstyle|}}}
}}

The btnstyle parameter accepts: bluebtn, whitebtn, negbtn, tight, or combinations.


Typography

Font Family Declaration

css
h1, .mw-heading1, h2, .mw-heading2, h3, .mw-heading3,
h4, h5 {
    font-family: "Montserrat", sans-serif;
    font-weight: bold;
    border-bottom: none;
}

Note: Montserrat is a Google Font not pre-loaded on Wikimedia wikis. For it to work, the wiki must load the font. On Meta, the font is loaded through the site-wide CSS. For custom projects, you have two options:

  1. Use system fonts — font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  2. Use a web font hosted on Commons — via @font-face pointing to a .woff2 file on Commons

Heading Sizes

css
h1 { font-size: 2rem !important; margin-top: 0; padding-top: 0; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.4rem !important; line-height: 1; }
h4 { font-size: 1.1rem; }

Banner Typography (Hero Section)

css
.bannertitle {
    font-weight: bold;
    font-size: 4rem;
}

.bannerbody {
    font-size: 2rem;
    line-height: 1.3;
}

.bannertime {
    font-size: 1rem;
    background: black;
    color: white;
    border-radius: 1em;
    padding: 0.1em 1em;
    width: max-content;
}

.bannersubtitle {
    font-weight: bold;
}

Article Metadata

css
.articlemeta {
    font-weight: bold;
    margin: 2em 0 1em;
    font-family: 'Montserrat', sans-serif;
    line-height: normal;
}

Capitalization

css
h1:first-letter, h2:first-letter, h3:first-letter,
h4:first-letter, h5:first-letter {
    text-transform: capitalize;
}

This ensures headings always start with a capital letter regardless of wikitext.


Responsive Breakpoints

Standard Breakpoints

BreakpointTargetCommon Changes
max-width: 1000pxSmall desktops / tabletsMenu collapses to vertical
max-width: 800pxTabletsTwo-column becomes single
max-width: 600pxMobile phonesFull stacking, smaller fonts

Menu Collapse (1000px)

css
@media only screen and (max-width: 1000px) {
    .menu ul li {
        padding: 0.2rem 0;
        margin-right: 0;
    }
    .menu ul {
        flex-direction: column;
    }
    .menu {
        margin: 1rem 0;
    }
}

Header Adapt (800px)

css
@media only screen and (max-width: 800px) {
    .headertitle {
        font-size: 4vw;
    }
}

Mobile Stack (600px)

css
@media only screen and (max-width: 600px) {
    .activity {
        position: relative;
        width: 100%;
        line-height: 1.4;
    }
    .activity .mainimage img.mw-file-element {
        height: 200px !important;
    }
    .articlerowinfo {
        flex-direction: column;
        align-items: start;
    }
    .full {
        flex-direction: column;
    }
    .bannerbackground {
        display: flex;
        flex-direction: column;
        padding: 2rem;
    }
    .bannertitle {
        font-size: 2rem;
    }
    .bannertexts {
        width: 100%;
    }
    .bannerbody {
        font-size: 1rem;
        padding-top: 0.5em;
    }
    .bannerimage {
        width: 100%;
        height: 70%;
    }
}

Pattern: Prefer em/rem over px for Breakpoints

css
/* Good — accessible: respects user font-size preferences */
@media only screen and (max-width: 62.5em) { ... }

/* Also fine for wiki pages where simplicity matters */
@media only screen and (max-width: 600px) { ... }

Skin Targeting (Vector / Minerva)

TemplateStyles supports skin-specific styling via the media attribute on <templatestyles>:

wikitext
<templatestyles src="Project/style.css" />
<templatestyles src="Project/mobile.css" media="screen and (max-width: 720px)" />

But a better approach is to use class overrides within the same CSS file:

css
/* Desktop Vector */
.my-card { padding: 2rem; }

/* Mobile Minerva */
.skin-minerva .my-card { padding: 1rem; }

/* Vector 2022 (new Vector) has its own skin class */
.skin-vector-2022 .my-card { border-radius: 4px; }

Common skin class names:

SkinCSS Class
Vector (legacy).skin-vector
Vector (2022).skin-vector-2022
Minerva (mobile).skin-minerva
Monobook.skin-monobook
Timeless.skin-timeless

Image Positioning & Object-Fit

When images are used as card thumbnails or hero banners, controlling how they fill their container is critical.

Object-Fit Classes

css
.mainimage img.mw-file-element {
    width: 100%;
    object-fit: cover;
    max-height: 450px;
}

/* Position the image to show the top portion (useful for portraits) */
.mainimage.top img.mw-file-element {
    object-position: top;
}

/* Position to bottom (useful for landscapes) */
.mainimage.bottom img.mw-file-element {
    object-position: bottom;
}

/* Don't crop — show the whole image with letterboxing */
.mainimage.contain img.mw-file-element {
    object-fit: contain;
}

/* Position at 25% from top (good for person photos — eyes centered) */
.person img {
    object-position: 50% 25%;
}

These classes are passed via the class parameter in templates:

wikitext
{{AvoinGLAM/Main navigation
  |image=File:Photo.jpg
  |class=person
}}

Card Image Sizing

css
.smallbox img {
    border-radius: 8px;
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.boximg img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
}

Table Image Sizing

css
.tableimg img {
    width: 150px;
    height: 150px;
    border-radius: 8px;
    object-fit: cover;
}

Hover Overlays and Transitions

The hover overlay pattern used on gallery items creates a "reveal info on hover" effect.

Overlay Pattern (White Semi-Transparent)

css
.work {
    flex: auto;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    text-align: center;
}

/* Invisible overlay that fades in on hover */
.work::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.85);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.work:hover::before {
    opacity: 1;
}

/* Hidden content that appears on hover */
.workdata {
    display: none;
}

.work:hover .workdata {
    display: flex;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    justify-content: center;
    align-items: center;
    color: #333;
    padding: 1em;
    text-align: center;
    flex-direction: column;
    width: 100%;
    z-index: 2;
    word-break: break-word;
    box-sizing: border-box;
}

Simple Hover Effects

css
/* Underline reveal on menu items */
.menu ul li {
    transition: 0.3s;
}
.menu ul li:hover {
    box-shadow: inset 0 -2px 0 #0E65C0;
}

/* Color change on hover */
.menu ul li:hover a {
    color: #0E65C0;
}

/* Grayscale to color */
.createarticle img {
    opacity: 0.5;
    filter: grayscale(1);
    transition: 0.3s;
}
.createarticle:hover img {
    opacity: 1;
    filter: grayscale(0);
}

Lua + TemplateStyles Integration

Lua modules (via Scribunto) can generate <templatestyles> calls programmatically.

From Lua: Emitting a Stylesheet Link

lua
local p = {}

function p.render(frame)
    -- Emit the stylesheet tag
    local css = '<templatestyles src="Project/style.css" />'
    -- Build content
    local html = css .. '<div class="my-box">Content</div>'
    return html
end

return p

From Lua: Adding a Class Name

lua
function p.card(frame)
    local color = frame.args["color"] or "whitebox"
    -- The CSS class is chosen dynamically
    local html = mw.html.create('div')
        :addClass('box')
        :addClass(color)
        :wikitext(frame.args["content"])
    return tostring(html)
end

Checking TemplateStyles from Lua

Use frame:extensionTag() to generate the templatestyles tag properly:

lua
function p.withStyles(frame)
    return frame:extensionTag('templatestyles', '', { src = 'Project/style.css' })
        .. '<div class="styled-content">' .. frame.args[1] .. '</div>'
end

Anti-Abuse Features and Scoping

CSS Scoping

TemplateStyles CSS is automatically scoped — each stylesheet is prefixed with a unique mw-parser-output ancestor selector. This means:

css
/* Your CSS */
.my-class { color: red; }

/* Gets transformed to: */
.mw-parser-output .my-class { color: red; }

This prevents TemplateStyles from affecting content outside the parser output area (e.g., site navigation, footer).

Sanitization Errors

If you use a disallowed property or value, the CSS rule is silently dropped — the page still renders, but your style won't apply. To debug:

  1. Open browser DevTools → Network tab → Find the load.php request for templatestyles
  2. Check the Response tab — invalid rules are omitted
  3. Alternatively, save the CSS to a sandbox page as sanitized-css and read the API error response — invalid rules are reported there

Flagged Properties

Some properties are allowed but flagged for review:

  • background-image with gradients is allowed; url() is blocked
  • position: fixed and position: absolute are allowed but may be flagged for accessibility review

Template Protection

High-use CSS templates should be protected at templateeditor or sysop level, just like high-use templates:

action=query&prop=info&inprop=protection&titles=Template:Project/style.css&format=json

Cascading Order & Specificity

Order of CSS application on a wiki page:

  1. Site-wide CSS (MediaWiki:Common.css, skin CSS)
  2. TemplateStyles CSS (in order of <templatestyles> tags on the page)
  3. Page-specific CSS (if any <style> tags exist — these are stripped on Wikimedia wikis for security)

Specificity: TemplateStyles has normal CSS specificity — it follows standard CSS cascade rules. Use more specific selectors to override:

css
/* Base style from TemplateStyles */
.smallbox h3 { font-size: 1.3em; }

/* Override on a specific page via another TemplateStyles inclusion */
.special-page .smallbox h3 { font-size: 1.5em; }

Multiple TemplateStyles: If two templates load different stylesheets that target the same element, the last one loaded wins at equal specificity.

TemplateStyles also deduplicates — if the same stylesheet is loaded twice (same hash), it's only included once.


Debugging TemplateStyles

Quick Checklist

IssueLikely Cause
Style doesn't applyProperty not in allowlist, or selector specificity too low
Style applies on template page but not in articles<noinclude> wrapping the <templatestyles> tag
Only some rules workDisallowed properties are silently dropped
Looks different on mobileMinerva skin has different defaults — use .skin-minerva overrides
Cache issuesAppend ?action=purge to the page, or wait for CDN purge

Checking if TemplateStyles is Loading

bash
# Does the page load any templatestyles?
curl -s "https://meta.wikimedia.org/w/api.php?action=parse&page=PageTitle&prop=modules&format=json" \
  -H "User-Agent: MyTool/1.0" | python3 -c "
import json, sys
data = json.load(sys.stdin)
modules = data.get('parse', {}).get('modules', [])
ts = [m for m in modules if 'templatestyles' in m]
print(f'TemplateStyles modules: {ts}' if ts else 'No TemplateStyles found')
"

Validating a CSS File

There is no action=templatestyles endpoint — validate CSS by saving it to a sandbox page as sanitized-css. A successful edit means it passed TemplateStyles validation; an API error returns the validation failure:

bash
# 1. Get a CSRF token
TOKEN=$(curl -s "https://meta.wikimedia.org/w/api.php?action=query&meta=tokens&type=csrf&format=json" \
  -H "User-Agent: MyTool/1.0" | python3 -c "import sys,json; print(json.load(sys.stdin)['query']['tokens']['csrftoken'])")
# 2. Save your CSS as sanitized-css (edit a sandbox page; API error = validation failure)
curl -s -X POST "https://meta.wikimedia.org/w/api.php" \
  -H "User-Agent: MyTool/1.0" \
  --data-urlencode "action=edit" \
  --data-urlencode "title=User:YourName/sandbox/styles.css" \
  --data-urlencode "text=.my-class { color: red; }" \
  --data-urlencode "contentmodel=sanitized-css" \
  --data-urlencode "token=$TOKEN" \
  --data-urlencode "format=json" | python3 -m json.tool

Visual Debugging

Use your browser's Inspect Element on the rendered page. TemplateStyles classes (.mw-parser-output .my-class) should appear in the Computed Styles panel.


Reference Links


Tooling

This skill includes helper scripts, reference docs, and template code.

🔧 Validate TemplateStyles CSS (scripts/validate-templatestyles.sh)

Check a CSS file or template against the TemplateStyles allowed-property allowlist:

bash
# Validate a local CSS file
./scripts/validate-templatestyles.sh path/to/style.css

# Validate directly from a wiki template
./scripts/validate-templatestyles.sh --wiki meta "AvoinGLAM/style.css"

# Show only warnings for disallowed properties
./scripts/validate-templatestyles.sh style.css --strict

🔧 Fetch Rendered TemplateStyles (scripts/fetch-templatestyles.sh)

Download the compiled, sanitized CSS from a TemplateStyles template page (what the browser actually receives):

bash
# Fetch the rendered CSS for inspection
./scripts/fetch-templatestyles.sh "AvoinGLAM/style.css" --wiki meta

# Compare source vs. rendered (spot what got stripped)
./scripts/fetch-templatestyles.sh "Project/style.css" --diff

📚 Allowed CSS Properties Reference (references/allowed-properties.md)

Complete categorized reference of all CSS properties, at-rules, and values allowed by TemplateStyles sanitizer.

📚 Layout Pattern Catalog (references/layout-patterns.md)

Reusable CSS Grid and Flexbox patterns with wikitext usage examples and responsive variants:

  • Single-column responsive
  • Multi-column card grids
  • Hero banner layouts
  • Sidebar + content layouts
  • Dashboard/dataviz layouts

📚 Design Theme Examples (references/design-themes.md)

Color palette suggestions, typography pairings, and complete theme CSS examples:

  • Blue/white professional theme
  • Warm/earthy community theme
  • Dark/accent theme for dashboards
  • High-contrast accessibility theme

🐍 TemplateStyles Inspector (assets/templatestyles_inspector.py)

Analyze a page for all TemplateStyles usage — which CSS templates are loaded, what CSS properties they define, and whether any disallowed properties are present:

bash
# Inspect TemplateStyles on a page
python3 assets/templatestyles_inspector.py "AvoinGLAM/Past activities" --wiki meta

# Show all CSS rules grouped by selector
python3 assets/templatestyles_inspector.py "Page" --rules

# Check for unsupported properties
python3 assets/templatestyles_inspector.py "Page" --lint

🐍 Grid Layout Preview (assets/grid_layout_preview.py)

Generate a visualization of how a CSS Grid configuration will look, given column min/max widths and gap:

bash
# Preview a grid layout
python3 assets/grid_layout_preview.py --min 150 --max 219 --gap 24

# Export grid CSS for a given number of items
python3 assets/grid_layout_preview.py --items 12 --columns 3 --gap 16 --output-css

🧪 Test Suite (tests/)

Test scripts for verifying tool functionality:

bash
# Run all tests
python3 -m pytest tests/

# Test the inspector against known pages
python3 -m pytest tests/test_inspector.py

# Test CSS validation rules
python3 -m pytest tests/test_validation.py

File inclusi

Il modello legge questi file quando servono, mentre la skill è caricata. Sono accessibili in sola lettura e non vengono mai eseguiti.

Domande frequenti

Cosa fa la skill IA Wikimedia Page Styling?

Use TemplateStyles to load custom CSS on wiki pages, then build responsive grid/flexbox layouts, card-based tile systems, color themes, button systems, and full visual design systems — transforming plain MediaWiki pages into rich, interactive-looking interfaces

Perché usare Wikimedia Page Styling su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Wikimedia Page Styling è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Wikimedia Page Styling in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/fuzheado/Wikipedia-AI-Skills/tree/main/.claude/skills/wikimedia-page-styling. TypingMind legge il file SKILL.md, include i file associati e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Wikimedia Page Styling?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Wikimedia Page Styling?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Wikimedia Page Styling: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Wikimedia Page Styling è gratuita?

Sì. È pubblicata su GitHub da fuzheado con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇