Manual:Interwiki - MediaWiki
Jump to content
From mediawiki.org
Translate this page
Languages:
Hausa
Türkçe
italiano
polski
português
română
suomi
čeština
русский
עברית
فارسی
हिन्दी
తెలుగు
ไทย
中文
한국어
Interwiki links
are links to pages of other projects, using a prefixed internal link style.
Interwiki links make it possible to link to pages of other websites such as Wikipedia, Wikibooks, Wikinews, etc. or to your wiki-project in different languages.
(See
Manual:Wiki family
.)
A link like
[[Wikipedia:Main Page]]
will appear like this:
Wikipedia:Main Page
and redirect you to Wikipedia's Main Page.
Interwiki links to other projects
Interwiki links can be viewed and edited from
Special:Interwiki
since MW 1.44, when Interwiki extension was merged into core.
Table and query API
Interwiki links are hosted in the
interwiki
table of the MediaWiki database.
You can retrieve the interwiki list from the
interwikimap
property of the
siteinfo
meta query API, in other words by making an API request like:
api.php
action=query
meta=siteinfo
siprop=interwikimap
[try in ApiSandbox]
Default
Several Wikimedia projects (and others) are ready for interwiki linking by default, so you can use them without editing your database.
The following are some examples of interwiki prefixes which are available by default (Wikipedia is also available, 1.10 and after):
prefix
destination URL
usage example
commons
[[commons:MediaWiki]]
mediazilla
[[mediazilla:1209]]
metawikimedia (before version 1.23: metawikipedia)
[[metawikimedia:Main Page]]
The full list of default interwiki prefixes is available at
maintenance/interwiki.list
See
Interwiki linking on Wikimedia wikis
for complete information on linking from/to Wikimedia projects.
In some installations, none of these are pre-installed.
Adding a new website for interwiki linking
Interwiki links are set in the
interwiki
table of the database.
These can be modified at
Special:Interwiki
by users that have the
interwiki
right. You might need to add the line
$wgGroupPermissions['sysop']['interwiki'] = true;
to your wiki's configuration for this to work. In MediaWiki 1.44 and later, this feature is built into MediaWiki core. Older versions can use the
Interwiki
extension.
Make sure the new prefix you are defining isn't already used by MediaWiki as an
interlanguage link
, otherwise it will be interpreted as such.
translatewiki:Special:MessageGroupStats/mediawiki
provides a list of interlanguage links currently defined. For example,
dtp:
would be interpreted as a page in Central Dusun language rather than a link to a desktop publishing site as you might have envisioned.
To test
To test configuration:
Go to your site,
create an article, with the following content:
[[wikipedia:Wikipedia:Village pump|]]
This should display a link to the 'Village pump' page on en.Wikipedia.org (the url
Field documentation
See also:
Manual:Interwiki table
Tip for wiki admins:
Several help pages link to MediaWiki.org's
Manual
namespace. To make these links work on your local wiki, add an interwiki link with
iw_prefix=manual
and
iw_url=http://www.mediawiki.org/wiki/Manual:$1
Tip for wiki admins:
$wgTranscludeCacheExpiry
in your
LocalSettings.php
should be set if changes in the transcluded wiki are done. Alternatively, you can flush the table
transcache
on your local wiki.
Interwiki links to other languages
Interwiki links to other languages
If you have installed a
Wiki family
, you can link from an article in English to an article in German (if you have a German project, too).
You can set up MediaWiki to show those links in the sidebar, just below the toolbox.
In your filesystem, there is a subfolder of your MediaWiki installation, called "languages".
Go there and have a look at
Names.php
as it contains a list of known languages and their prefixes.
E.g. you want to add your German project, search
Names.php
for "Deutsch" and note the prefix "de".
If you know the "right" prefix, edit your database by adding a new line to table
interwiki
iw_prefix
language-prefix (e.g. "de" for German), which is listed in
Names.php
iw_url
URL to your wiki-project (e.g.
iw_local
see
Manual:Interwiki table
iw_trans
see
Manual:Interwiki table
Now, you can link an article to the same in other languages.
Adding
[[de:Hauptseite]]
on your English Main_Page will create a link "Deutsch" below the toolbox, which leads to the Main_Page of the German wiki (Hauptseite).
Note, that this link is shown in Sidebar's section,
only
, and not inside of the article.
If you want to create a link inside of the text, you have to add a colon before the prefix:
[[:de:Hauptseite]]
or set
$wgInterwikiMagic
to false.
Exporting the interwiki table from a wiki
The following JavaScript code performs the API query to retrieve the interwiki map of an existing wiki, then displays the SQL INSERT statements to fill the interwiki table on a new wiki. You run it for example by injecting the code through your browser's developer tools, or by placing it inside Special:MyPage/
skinname
.js and previewing.
function
ExtractInterwikiMapTable
()
getJSON
mw
config
get
'wgScriptPath'
'/api.php?action=query&meta=siteinfo&siprop=interwikimap&format=json'
function
data
var
iw_prefix
iw_url
iw_local
iw_api
re_escape
/(')/g
result
''
for
var
iwm
data
query
interwikimap
iwm
length
++
iw_prefix
"'"
iwm
].
prefix
replace
re_escape
'\\$1'
"'"
iw_url
"'"
iwm
].
url
replace
re_escape
'\\$1'
"'"
iw_local
typeof
iwm
].
local
==
'string'
'1'
'0'
iw_api
"'"
iwm
].
iw_api
||
''
).
replace
re_escape
'\\$1'
"'"
result
+=
'INSERT INTO interwiki (iw_prefix, iw_url, iw_local, iw_trans, iw_api) VALUES ('
iw_prefix
', '
iw_url
', '
iw_local
', 0, '
iw_api
');\n'
'