Manual:Guide to setting up interwiki linking

Jump to: navigation, search
Language:Project:Language policy English  • français
To set up a language-family of wikis connected by interwiki links, see Manual:Wiki family.


This page was moved from MetaWiki.
It probably requires cleanup – please feel free to help out. In addition, some links on the page may be red; respective pages might be found at Meta. Remove this template once cleanup is complete.

MediaWiki uses certain namespaces as pointers to articles on different wikis; these work by simple URL substitution, so can point to non-wiki sites just as easily. These are known as interwiki links, and w:en:Interwiki links is an example of such a link. They are stored in the database, as a prefix, a URL, and a "local" flag, which is used to mark any that are "sister projects" within the same organisation, and should have certain properties enabled. In some versions, there is also a "trans" flag; leaving both of these as '0' should be safe.

Database[edit source]

Remember that your actual database and wikiuser name were specified by you, and are stored in LocalSettings.php.

Using phpMyAdmin instead (preferred method - simpler)[edit source]

If your server uses the software phpMyAdmin:

  1. Select the wiki database (remember that your actual database and wikiuser name were specified by you, and are stored in LocalSettings.php),
  2. Select the table "interwiki" from the sidebar.
  3. Click the "browse" tab at the top to see all of the existing interwiki links.
  4. Click the "insert" tab at the top.
  5. In the iw_prefix/value box add the name of the new interwiki that will be used on all wikipages to interwiki to an external site. (Example: Add "wikipedia" to the iw_prefix/value box. Users can then type [[Wikipedia:bridges]] to link to Wikipedia's page on bridges)
  6. In the iw_url/value box add the internet address of the interwiki link. "$1" is what will be replaced with whatever follows the interwiki prefix in your code; it will usually be at the end of the URL for the site for which you want to make a shortcut. (Example: Add$1)
    1. Since Version 1.11 of MediaWiki the Interwiki table iw_url/value gets saved as BLOB and entering it directly doesn't work anymore. You first to change the type of iw_url/value to TEXT.
  7. Click the Go button.

Mysql method[edit source]

 mysql -u wikiuser -p wikidb

Change wikiuser and wikidb to the username and database name for your wiki ($wgDBuser and $wgDBname). When prompted, enter your password.

Example[edit source]

$ mysql -u root -p wikidb
Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 150
Server version: 5.6.24-0ubuntu2 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


View interwiki table[edit source]

The names of the tables that store information about interwiki begin with interwiki, or if you are using a table prefix, it's yourprefix_interwiki. The following assumes no table prefix.

Type interwikiTab Tab to see a list of interwiki-related tables:

mysql> interwiki
interwiki            interwiki.iw_prefix
interwiki.iw_local   interwiki.iw_url
mysql> interwiki 

The primary table is 'interwiki'.

To see how many entries there are in the table, enter

SELECT COUNT(*) FROM interwiki;

To see the interwiki prefixes, enter:

SELECT * FROM interwiki;

See for more information on retrieving data from an SQL table.

Edit interwiki table[edit source]

Add your own custom[edit source]

You can follow the format of the next section to create your own interwiki links to add..


REPLACE INTO interwiki (iw_prefix,iw_url,iw_local) VALUES

mysql -u <username> -p <nameofyourdatabase> < <filename.sql>

mysql -u wikiuser -p wikidb < bugzilla-interwiki.sql

This does not report success when it works. If you want to double check, you have to check the interwiki table.

Add Wikimedia's shorter interwiki list[edit source]

The default MediaWiki install adds the popular interwiki map in maintenance/interwiki.sql. The file wikipedia-interwiki.sql in Extension:WikimediaMaintenance has shorter interwiki links for Wikimedia wikis, such as:

REPLACE INTO /*$wgDBprefix*/interwiki (iw_prefix,iw_url,iw_local) VALUES

To add these, download the extension and run, roughly

$ php maintenance/sql.php extensions/WikimediaMaintenance/wikipedia-interwiki.sql
Query OK, 40 row(s) affected

Opening interwiki-links in a new window[edit source]

See Manual:Opening external links in a new window

More MySQL help[edit source]


Adding interwiki prefixes through Special:Interwiki[edit source]

By default, your wiki will come with Extension:Interwiki and a prepackaged set of interwiki prefixes, and also by default you will not be able to edit them. To enable editing of the interwiki table - a right that is usually limited to sysops when it is enabled - insert the following line into LocalSettings.php:

$wgGroupPermissions['sysop']['interwiki'] = true;

Sysops will now be able to add and remove interwiki prefixes from the interwiki table by going to Special:Interwiki. If you would prefer to give this right to another user group, simply replace sysop with the name of that group.

Admin tips[edit source]

On my MediaWiki 1.4.7, I was obliged to activate the interwiki feature by creating first an interwiki link as wiki administrator. Before no interwiki link was active, after they were. I could even delete the link afterward, interwiki stay active. Don't know why jdd 14:19:51, 2005-08-08 (UTC)

Do not create an interwiki prefix which is the same as an existing namespace on your wiki. I have a larger project, called "I2U2", for which the wiki is only one component, for a glossary. I wanted an interwiki link to the main page of the whole project, not just the wiki, but calling it "i2u2" produces a link to the namespace, not the local link I had hoped for. --Eric Myers 13:59, 13 June 2006 (UTC)

Interwiki links use[edit source]

To use the interwiki link, simply insert where advisable


The first colon is optional here. The optional target after the right colon will replace the placeholder "$1" you have written after the URL in the database table. You will probably add here the link to the actual page within the target site.

Language links[edit source]

If the iw-link is made of any language shortcut found in the Names.php file, it has a different behavior. Examples below are for the english "en" shortcut.

  • [[en:target]] placed anywhere in a page is not displayed in the page but triggers the display of the "other languages" menu on the left of the screen, with the language name shown sending to the en:target interwiki link, as defined in the database.
  • Alas, any occurrence of this tag triggers the appearance of the language name, so only one (for each language involved) must be inserted on the page.
  • If you want to have the link visible elsewhere in the page, you must use the [[:en:target]] variant (two colons).

N.B. interwiki language links don't work on this actual page. This kind of link is not activated (unusefull) on MediaWiki pages. You can see them in action on

Non-standard language/other side bar links[edit source]

There may be a time when you want your interwiki links to appear in the siderbar, instead of in-text. To achieve this, simply add the interwiki prefix and the name of the site to /languages/Names.php, in the same format as the languages already there:

'iw_prefix' => 'Description of language/site',

Make sure the last line has no comma, and the second last line has one, and make sure your interwiki prefix is not not duplicating an existing language!

Maintenance script[edit source]


When upgrading from a 1.2 to 1.3, your interwiki table will be created. However, it will not be updated on further upgrades.

Use_wikipedia.27s_interwiki_list shows how to use it.

Undocumented feature[edit source]

Q: I'm puzzled about doing Interwiki links, the Interwiki.php is obsoleted... how do you set up interwiki links?

A: Before we can answer that, we must ask another question: do you need language links or just external interwiki links?

To set up new interwiki link prefixes, you stick them into the 'interwiki' table in the database (which is undocumented... the source code is the documentation).

  • Sample sql in the maintenance dir. Basically:
iw_prefix  iw_url  	                iw_local
fr 	   http://fr.yourdomain.tld/$1 	1
  • maintenance/interwiki.sql defines the standard prefixes.
  • wikipedia-interwiki.sql has the wikipedia language prefixes.
  • wiktionary-interwiki.sql has the wiktionary prefixes.
  • set the magic global on then, and mark the local prefixes as local in the db
  • $wgInterwikiMagic = true; # Treat language links as magic connectors, not inline links
    • default is true
      • This does not appear to be the case in MediaWiki version 1.5.3. Adding this variable to LocalSettings.php solved this.
  • The 'iw_local' field in the interwiki table is currently only used for the redirect feature. Inline or 'other languages' box is determined by whether the prefix is in the array of language codes/names defined in the language file ($wgExtraLanguageNames).

Case tested since 1.9.0 version[edit source]

Example: To enable interlanguage links from an english wiki ( to spanish wiki ( with MySQL sentences:

1. Open to use the source wiki database (english);

USE wikifoo_englishdb;

2. Check if the interwiki link prefix already exists:

SELECT * FROM interwiki WHERE iw_prefix = "en";

If exist, we can delete the row:

DELETE FROM interwiki WHERE iw_prefix = "en";

3. Add our prefix rule:

INSERT INTO interwiki (iw_prefix, iw_url, iw_local, iw_trans) VALUES ("es", "$1", 0, 0);

Note: to enable vice-versa interlanguage links (from spanisk wiki to english wiki), we need to do the same procedure in the spanish wiki database.

External redirecting example[edit source]

Example with MySQL to enable a redirect to a forum, using interwiki:

INSERT INTO interwiki (iw_prefix, iw_url, iw_local, iw_trans) VALUES ("helpforum", "", 1, 0);

Then you can put the redirect tag in the Help page in the sidebar:

#REDIRECT [[helpforum:]]

Questions and Answers[edit source]

Q: Even after modifying the Names.php file to alter one of the existing language prefixes to allow a different (non-language) interwiki link to be created with its prefix instead, and after adding the (non-language) prefix and link successfully to the 'interwiki' table, the new (non-language) prefix cannot successfully be used inside of a wiki page (it appears instead as an "other language" and also does not appear in the main body of the wiki page where the prefix code has been placed). (The variable $wgInterwikiMagic is not present in my LocalSettings.php file, and adding it to be true (or false) did not help.)

A: To override one of the entries in Names.php add $wgExtraLanguageNames['it']=''; to your LocalSettings.php. This example would essentially remove Italian from the list and allow you to make interwiki links for 'it:'.

Next page: Custom skins >

Creative Uses[edit source]

Bugzilla links[edit source]


See it in action at Add_your_own_custom

See also[edit source]