MediaWiki Interwiki Links — Interwiki Prefixes, Database Config, and Wikimedia Projects
In this tutorial, you will learn about MediaWiki Interwiki Links. We cover key concepts, practical examples, and best practices to help you master this topic.
Interwiki links in MediaWiki are shorthand cross-references that connect pages across wikis using configurable prefixes — enabling shortcuts like [[wikipedia:MediaWiki]] instead of full URLs, with prefix mappings stored in the database and extensible to any external wiki, exactly as Wikipedia uses interwiki links to reference sister projects.
What You'll Learn
- Understanding interwiki link syntax
- Configuring interwiki prefixes in the database
- Adding custom prefixes for external wikis
- Using Wikimedia project prefixes
- Managing interwiki links with Special:Interwiki
- Security considerations for interwiki links
Why It Matters
Interwiki links turn a single wiki into part of a connected ecosystem. A documentation wiki can link to Wikipedia articles for background concepts, to a partner wiki for related products, and to a bug tracker for issue references. Instead of typing full URLs like https://en.wikipedia.org/wiki/Encryption, users write [[wikipedia:Encryption]]. This keeps links readable, maintainable, and consistent across the wiki.
Real-World Use
A DodaTech documentation wiki configures interwiki prefixes for Wikipedia, a partner API documentation wiki, an internal bug tracker, and a Stack Overflow tag. Writers use [[wikipedia:OAuth]] to link to OAuth explanation, [[apidocs:authentication]] for the partner's docs, [[bugtracker:423]] for a specific issue, and [[stackoverflow:mediawiki-api]] for community Q&A. All configured from one admin interface.
Learning Path
flowchart LR A["28: Scribunto & Lua"] --> B["29: Cite & References"] B --> C["30: Interwiki Links"] C:::current D["31: Wiki Farms"] E["32: Content Translation"] F["33: Import & Export"] C --> D --> E --> F classDef current fill#38bdf8,color#0f172a,stroke-width:2px
What Are Interwiki Links?
An interwiki link uses a short prefix to reference a page on another wiki. The syntax is:
[[prefix:pagename]]
For example, [[wikipedia:MediaWiki]] renders as a link to https://en.wikipedia.org/wiki/MediaWiki. The text after the colon is the page title on the target wiki.
Interwiki vs External Links
| Feature | Interwiki Link | External Link |
|---|---|---|
| Syntax | [[wikipedia:Page]] |
[https://example.com Page] |
| Readability | Clean, short | Full URL visible |
| Maintainability | Change one prefix config | Must update every URL |
| Link style | Same as internal links | Different style (arrow icon) |
| Works offline | Yes (displays as plain text) | No (URL visible) |
Step 1: Understand Default Interwiki Prefixes
MediaWiki comes with preconfigured interwiki prefixes for Wikimedia projects:
| Prefix | Target |
|---|---|
wikipedia |
https://en.wikipedia.org/wiki/ |
wiktionary |
https://en.wiktionary.org/wiki/ |
wikiquote |
https://en.wikiquote.org/wiki/ |
wikibooks |
https://en.wikibooks.org/wiki/ |
wikisource |
https://en.wikisource.org/wiki/ |
wikinews |
https://en.wikinews.org/wiki/ |
wikiversity |
https://en.wikiversity.org/wiki/ |
wikimedia |
https://wikimediafoundation.org/wiki/ |
commons |
https://commons.wikimedia.org/wiki/ |
meta |
https://meta.wikimedia.org/wiki/ |
mediawikiwiki |
https://www.mediawiki.org/wiki/ |
These work immediately without configuration. Type [[wikipedia:CMS]] on any page and it links to the Wikipedia article on content management systems.
Step 2: View and Manage Prefixes
Special:Interwiki
The Special:Interwiki page lists all configured interwiki prefixes. It shows:
Prefix | URL | Forward
────────────────|──────────────────────────────────|────────
acronym | https://www.acronymfinder.com/… | No
commons | https://commons.wikimedia.org/… | No
mediawikiwiki | https://www.mediawiki.org/wiki/ | No
wikipedia | https://en.wikipedia.org/wiki/ | No
Adding a Prefix via Special:Interwiki
- Go to
Special:Interwiki - Click "Add an interwiki prefix"
- Fill in:
- Prefix:
dodatech - URL:
https://wiki.dodatech.com/wiki/$1 - Transclude: Unchecked (usually)
- Forward: Unchecked
- Prefix:
- Click "Submit"
Now [[dodatech:MediaWiki]] links to https://wiki.dodatech.com/wiki/MediaWiki.
Editing and Removing Prefixes
Click the "Edit" or "Delete" links next to each prefix on Special:Interwiki. Changes take effect immediately.
Step 3: Configure Interwiki via the Database
You can also manage interwiki prefixes directly in the database.
interwiki Table Structure
The interwiki table has these columns:
CREATE TABLE interwiki (
iw_prefix VARCHAR(32) NOT NULL PRIMARY KEY,
iw_url VARCHAR(255) NOT NULL,
iw_api VARCHAR(255) NOT NULL,
iw_wikiid VARCHAR(64) NOT NULL,
iw_local BOOLEAN NOT NULL DEFAULT false,
iw_trans BOOLEAN NOT NULL DEFAULT false
);
Adding a Prefix via SQL
INSERT INTO interwiki (iw_prefix, iw_url, iw_api, iw_wikiid, iw_local, iw_trans)
VALUES (
'dodatech',
'https://wiki.dodatech.com/wiki/$1',
'',
'',
false,
false
);
The $1 placeholder is replaced with the page name from the interwiki link.
Bulk Import
For bulk imports, use the maintenance/importInterwiki.php script:
php maintenance/importInterwiki.php --source=interwiki.csv
CSV format:
prefix,url,api,wikiid,local,trans
dodatech,https://wiki.dodatech.com/wiki/$1,,,0,0
partner,https://partnerwiki.com/wiki/$1,,,0,0
Step 4: Interwiki Transclusion
Interwiki transclusion allows including content from another wiki on your page. This requires the iw_trans flag to be enabled.
Enabling Interwiki Transclusion
UPDATE interwiki SET iw_trans = true WHERE iw_prefix = 'commons';
Transcluding External Content
{{commons:File:Logo.svg}}
This transcludes the file from Wikimedia Commons as if it were local. The content appears on your page as if it were uploaded to your wiki.
Security Considerations
- Enable transclusion only for trusted wikis: Transcluding from an untrusted wiki can introduce malicious content
- Wikimedia Commons transclusion is safe: Commons files are moderated
- Performance: Remote transclusion adds load time to your pages
Step 5: Interwiki Links in URLs
Interwiki prefixes can appear in URLs for convenient linking:
https://yourwiki/wiki/Wikipedia:Encryption
If Wikipedia is an interwiki prefix, this redirects to https://en.wikipedia.org/wiki/Encryption. This only works if the interwiki prefix is configured.
URL Forwarding
Enable URL forwarding for an interwiki prefix:
UPDATE interwiki SET iw_local = true WHERE iw_prefix = 'wikipedia';
With iw_local = true, the prefix appears as an interlanguage link in the sidebar.
Step 6: Custom Prefixes for Common Targets
Example: GitHub Issues
Add a prefix for GitHub issues:
- Go to
Special:Interwiki - Add prefix:
github - URL:
https://github.com/dodatech/$1 - Submit
Usage: [[github:dodabrowser/issues/42]] links to issue 42.
Example: PHP Documentation
Add a prefix for PHP docs:
- Prefix:
php - URL:
https://www.php.net/manual/en/$1.php
Usage: [[php:function.strlen]] links to the strlen documentation.
Example: Stack Overflow
- Prefix:
stackoverflow - URL:
https://stackoverflow.com/questions/tagged/$1
Usage: [[stackoverflow:mediawiki]] links to MediaWiki-tagged questions.
Example: MDN Web Docs
- Prefix:
mdn - URL:
https://developer.mozilla.org/en-US/docs/Web/$1
Usage: [[mdn:HTML/Element/a]] links to the anchor element docs.
Step 7: Interwiki Links in Templates
Templates can use interwiki links dynamically:
= Template:SeeWikipedia =
See the Wikipedia article on '''[[wikipedia:{{{1|}}}|{{{1|}}}]]''' for more information.
Usage: {{SeeWikipedia|MediaWiki}} renders a link to the Wikipedia article on MediaWiki.
Dynamic Interwiki with Lua
function p.interwikiLink( frame )
local prefix = frame.args[1] or "wikipedia"
local page = frame.args[2] or ""
return "[[" .. prefix .. ":" .. page .. "|" .. page .. "]]"
end
What You Learned
- Interwiki links use
[[prefix:pagename]]syntax - Wikimedia project prefixes are preconfigured
Special:Interwikimanages prefixes through a GUI- The
interwikidatabase table stores prefix configurations - Interwiki transclusion includes external content
- Custom prefixes connect to any external wiki or website
- Templates can build interwiki links dynamically
In the next lesson, you'll learn about wiki farms — running multiple wikis from one installation.
Common Mistakes
| Mistake | Why It Happens | How to Fix |
|---|---|---|
| Interwiki link renders as plain text | Prefix not configured | Add the prefix via Special:Interwiki or directly in the database. Verify the spelling matches exactly. |
| Interwiki link goes to wrong URL | Incorrect URL pattern | Check the URL format. It must include $1 as the page name placeholder. Example: https://en.wikipedia.org/wiki/$1. |
| Interwiki transclusion does not work | iw_trans flag not set | Update the database: UPDATE interwiki SET iw_trans = true WHERE iw_prefix = 'prefix'. Transclusion must also be enabled for the source wiki. |
| Cannot edit interwiki prefixes | Insufficient permissions | Only users with the interwiki permission can manage prefixes. By default, only bureaucrats have this right. |
| Prefix conflicts with existing namespace | Prefix matches a namespace name | If a namespace with the same name exists, the namespace takes priority. Choose a prefix that does not conflict with existing namespaces. |
Practice Questions
- What is the syntax for an interwiki link pointing to the Wikipedia article "MediaWiki"?
- How would you add a custom interwiki prefix for the DodaTech wiki at https://wiki.dodatech.com?
- What is the difference between interwiki linking and interwiki transclusion?
- Challenge: Build an interwiki ecosystem. Configure interwiki prefixes for Wikipedia, Wikimedia Commons, and two custom targets (e.g., a GitHub Repository and a PHP documentation site). Create a wiki page that uses all four prefixes in context. Add a prefix for a partner wiki and test interwiki transclusion by embedding a Commons image using
[[commons:File:Example.jpg]]. Create a template called "ExternalRef" that takes a prefix and page name and generates a formatted interwiki link with an icon. Finally, verify all links work correctly and open in the same or new tab as configured.
FAQ
Mini Project
Goal: Build a connected wiki ecosystem using interwiki links.
- Configure default Wikimedia interwiki prefixes (verify they work)
- Add custom prefixes for:
- Your own wiki (dodatech)
- A GitHub repository (github)
- MDN Web Docs (mdn)
- PHP documentation (php)
- Stack Overflow (stackoverflow)
- Create a "Resources" wiki page that uses all prefixes
- Enable interwiki transclusion for a trusted wiki
- Create a template "InterwikiRef" that formats interwiki links consistently
- Create a second wiki page "See Also" that links to related interwiki resources
- Test all links by clicking them
- Restrict the interwiki management permission to bureaucrats only
- Back up the interwiki table configuration
What's Next
Interwiki links connect wikis. Now let's look at running multiple wikis from a single codebase.
Continue to Lesson 31: Wiki Farms — learn how to set up and manage a wiki farm with shared code and separate databases.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro