Embedding Semantic MediaWiki: Techniques for Enhanced Accessibility

When a wiki starts to speak a richer language than plain text, you instantly get a double‑edged sword: the data becomes more powerful, but the markup also grows heavier

Embedding Semantic MediaWiki: Techniques for Enhanced Accessibility

When a wiki starts to speak a richer language than plain text, you instantly get a double‑edged sword: the data becomes more powerful, but the markup also grows heavier. The goal, then, is to stitch the semantic layer in a way that screen‑readers, keyboard‑only users, and anyone relying on assistive tech can still glide through the content without hitting a wall.

Why semantic matters for accessibility

Semantic MediaWiki (SMW) lets you declare properties and relationships right inside wiki pages. Think of it as a hidden spreadsheet that lives under the page’s narrative. For a sighted user, the wiki looks the same—but for a machine, there’s a tidy graph to query.

  • Structured data can be exposed via aria‑labels or role attributes, giving screen‑readers context that would otherwise be lost.
  • Query results can be rendered as accessible tables rather than raw wiki markup.
  • Templates that inject semantic triples can also inject ARIA landmarks, keeping the DOM clean.

1. Property definitions with accessibility in mind

Start by naming properties clearly. Avoid cryptic abbreviations; they become part of the generated title attributes. A good practice is to add a description that doubles as an aria‑description for the property itself.

# Define a human‑readable property
[[Property:HasReference::+]]
[[Has type::URL]]
[[Has description::"Link to a source that backs up the statement"]]

The snippet above does three things: it creates the property, tells SMW it expects a URL, and stores a description. Later, when a template renders that property, you can pull the description into an aria‑label automatically.

2. Semantic templates that respect the DOM

Templates are the workhorses of SMW. If you’re not careful, they can spit out <div> after <div> with no semantic meaning, and that’s a nightmare for a screen‑reader. The trick is to wrap semantic output in native HTML elements that already have built‑in accessibility roles.

<!-- File: Template:InfoboxPerson -->
<section class="infobox" aria‑label="Person summary">
  <h2>{{{name}}}</h2>
  <dl>
    <dt>Born</dt>
    <dd>{{#ask: [[Category:Person]] [[Has birthdate::+]] | format=external}}</dd>
    <dt>Occupation</dt>
    <dd>{{#ask: [[Category:Person]] [[Has occupation::+]] | format=external}}</dd>
  </dl>
</section>

Notice the <section> element with aria‑label. It tells assistive tech “this block is a summary about a person.” The <dl> (definition list) naturally conveys term‑definition pairs, which is exactly what you need for birthdates and occupations.

3. Query pages that output accessible tables

SMW’s #ask parser function can spit out results in dozens of formats. The default table format is OK, but you should add a few ARIA hooks so a visual‑impaired user can jump straight to the header row.

{{#ask:
 [[Category:Research Paper]]
 |?Has author
 |?Published date
 |format=table
 |link=all
 |mainlabel=-
 |offset=0
 |limit=25
 |headers=show
 |class=accessible-table
}}

Now sprinkle a little CSS and a bit of JavaScript (if you must) to attach role="grid" and aria‑rowcount dynamically. For most browsers, the extra markup is harmless, but it lets NVDA or VoiceOver announce “table with 5 columns, 20 rows.”

4. Leveraging Semantic Forms for keyboard‑first users

Enter Semantic Forms, the extension that turns form fields into SMW triples. A well‑crafted form can be fully navigable with Tab and Enter—no mouse required.

  • Use <input type="text"> with aria‑required="true" for mandatory fields.
  • Group related fields inside a <fieldset> with a <legend> that mirrors the SMW property label.
  • Provide clear error messages inside an element with role="alert" so screen‑readers announce them immediately.
<form id="new‑project">
  <fieldset aria‑describedby="proj‑desc">
    <legend>Add a new project</legend>
    <label for="proj‑name">Project name</label>
    <input id="proj‑name" name="Has project name" type="text" required aria‑required="true">
    <label for="proj‑owner">Owner</label>
    <input id="proj‑owner" name="Has owner" type="text">
    <div id="error‑msg" role="alert"></div>
    <button type="submit">Save</button>
  </fieldset>
</form>

Behind the scenes, Semantic Forms will translate those fields into [[Has project name::…]] and [[Has owner::…]]. The user never sees the raw triples, but the data becomes queryable.

5. ARIA‑rich output for inline queries

Sometimes you want a one‑liner on a page that pulls a value from the SMW store. Wrap the output in a <span> with an aria‑label that explains what the number means.

<span class="inline‑stat" aria‑label="Number of open tickets">
 {{#ask: [[Category:Ticket]] [[Status::Open]] | format=count }}
</span>

The screen‑reader will read “Number of open tickets, 42”, instead of just “42”. Small tweak, big win.

6. Testing the accessibility loop

All the code in the world means nothing if you never give it a spin with an assistive tool. A quick checklist:

  1. Run WAVE on pages that contain #ask results. Look for missing th elements.
  2. Navigate with Tab only. Ensure you can reach each form field, each query link, and each landmark region.
  3. Fire up NVDA (or VoiceOver) and listen to a page that includes a semantic template. Does it announce the section label?
  4. Check keyboard focus outlines; don’t hide them with CSS outline:none. Accessibility lovers thank you.

It’s easy to overlook a stray role="presentation" that strips meaning from a table cell. That’s why a manual test alongside automated tools is the best guard.

7. Real‑world case study: an enterprise architecture wiki

One organization (Sogeti Labs, see their blog post) built a living architecture repository using SMW. They faced the classic conundrum: engineers wanted deep, linked data; auditors needed clear, accessible reports. Their solution combined the techniques above:

  • Properties like Has component and Depends on were defined with short, descriptive labels.
  • Every component page used a <section aria‑label="Component overview"> that wrapped a definition list of attributes.
  • Dynamic queries generating CSV downloads also produced an HTML preview with an accessible table, satisfying both machine‑readable and human‑readable needs.

The result? A knowledge base that passed WCAG 2.1 AA audits without a massive rewrite, simply because semantics and accessibility were baked in from day one.

8. Tips for staying future‑proof

Technology moves fast—new versions of MediaWiki, ARIA 1.2, and even SMW’s query engine surface regularly. To keep your wiki both semantic and accessible:

  • Document your property glossary. Keep a page that lists each property, its type, and its ARIA description. Future contributors will copy‑paste instead of guessing.
  • Version‑lock extensions carefully. A new SMW release may change default output formats; test accessibility after each upgrade.
  • Leverage community resources. The MediaWiki accessibility guide is a living document that evolves alongside the core.
  • Automate linting. Tools like axe-core can be run in a CI pipeline to flag missing ARIA attributes before they land on production.

Conclusion

Embedding Semantic MediaWiki isn’t just about making your data queryable; it’s also a chance to make that data reachable for everyone, no matter how they consume the web. By defining clear properties, wrapping templates in proper landmarks, outputting ARIA‑enhanced tables, and rigorously testing with real assistive technology, you turn a powerful knowledge base into an inclusive one.

In short, think of semantics as the scaffolding and accessibility as the safety net. Build one without the other, and the structure feels shaky. Put them together, and you have a solid, user‑friendly platform that can grow with your organization’s needs.

Subscribe to MediaWiki Tips and Tricks

Don’t miss out on the latest articles. Sign up now to get access to the library of members-only articles.
jamie@example.com
Subscribe