MediaWiki Create or Update Template icon

MediaWiki Create or Update Template

Create or update a template in a MediaWiki page

MediaWiki Create or Update Template

AI-generated

Summary

Creates or updates a named template (e.g. {{Infobox}}) on a MediaWiki page by logging in with bot credentials, merging the supplied variables into the template's existing parameters, and saving the page via the MediaWiki edit API.

Inputs

  • Wiki URL — Overrides the site URL from credentials; requests go to /api.php (trailing slash trimmed).
  • Page Title (required) — Title of the page to edit. A nonexistent page is treated as empty content, so saving will create it.
  • Template Name (required) — Template name without braces. Matched case-insensitively against {{Name|...}} or {{Name}} on the page; the first match is used.
  • If template does not exist in page — 'Create it' (default) inserts a new template; 'Fail' throws an error and makes no edit.
  • Position — Where a newly created template goes: top of page (default) or end of page. Ignored if the template already exists.
  • Template Variables — List of name/value pairs. Existing parameters with the same name are overwritten, new ones are added, and other existing named parameters are kept.
  • Edit Summary — Edit summary saved in page history. Defaults to 'Updated via n8n'.

Output shape

One item per input item with json: { success: true, pageTitle, templateName, result }, where result is the 'edit' object returned by the MediaWiki API (e.g. result status, page title, revision IDs).

The template is rewritten in a normalized multi-line format ({{Name\n|key=value\n...}}). Only named parameters are preserved; positional (unnamed) parameters in an existing template are dropped. Each item performs a full login, fetches tokens and the page, then edits. With Continue On Fail enabled, failed items return json { error: message } instead of throwing. Login or edit errors raise a node error.

Examples

Example 1: Update the status field of an Infobox on a wiki page, adding it if missing at the top

Page Title: 'Project Alpha'; Template Name: 'Infobox'; If template does not exist: Create it; Position: Top of Page; Variables: status=Active; Edit Summary: 'Sync status from n8n'

Example 2: Only modify an existing template and error out if it's absent

Page Title: 'Main Page'; Template Name: 'Header'; If template does not exist: Fail; Variables: author=John Doe

Example 3: Target a different wiki than the one in credentials

Wiki URL: https://wiki.example.com; Page Title and Template Name set from incoming item expressions; Position: End of Page

Links

Discussion