User:Michael Große (WMDE)/WikibaseSiteLinksDoku

Jump to navigation Jump to search

The following text is a draft for explaining how to enable sitelinks on 3rd party Wikibase installations. It is to be inserted as another h2 on Wikibase/Installation.

Enable Sitelinks[edit]

Sitelinks are special links that contain a site and a title, and go from individual Items to pages on other wikis. In Wikidata these go to other Wikimedia sites such as Wikipedia, Wikisource and Wikivoyage. Among other things, Sitelinks are used to allow referencing a property of the Item on the linked page in the client wiki, a feature that is called Direct access.

1. Configure your sitelink groups[edit]

First, you need to think about how to group the client-wikis you want to see in your sitelinks area on the Items in your repo-wiki.

Define custom groups[edit]

In your repo-wiki, replace the content of $wgWBRepoSettings['siteLinkGroups'] in LocalSettings.php with the groups you would like to see there.

For example, consider the following line being added to LocalSettings.php:

$wgWBRepoSettings['siteLinkGroups'] = [ 'wikipedia', 'mywikigroup', 'anothergroup' ];

This will allow three groups in the SiteLinks box on the Item's page:

  • the standard defined wikipedia for the global Wikipedia sites
  • two custom wikis groups – here named mywikigroup and anothergroup just for example

The names defined here will be relevant to the site_group field in the sites table as specified below.

Deactivate the sitelinks feature[edit]

If you do not want your installation to make use of sitelinks at all, then you can deactivate that feature by setting the configuration to an empty array:

$wgWBRepoSettings['siteLinkGroups'] = [];

2. Localize your own groups[edit]

To show the correct heading for your own groups, you have to create the page MediaWiki:Wikibase-sitelinks-mywikigroup[1] with the desired heading as text.
You can create subpages to set the heading in different languages, e.g. MediaWiki:Wikibase-sitelinks-mywikigroup/de to create the German heading.

3. Add the Wikis to the sites table[edit]

To be able to add sitelinks to Items in your repo-wiki, you need add the client-wikis to the sites table. Take care that the group name used there must be one of the group names you added above. Following the example above, for instance, there would be one or more sites with mywikigroup and anothergroup as text in the site_group field.
Please also note that you need to set both the file path and the page path, and they do need to include the $1 placeholder. For further details on how to add sites to the table, please see these specific instructions.

After any modification made to Mediawiki's sites table, you should rebuild Wikibase's wb_items_per_site table. To do that, run the following command from your repo-wiki root directory: php extensions/Wikibase/repo/maintenance/rebuildItemsPerSite.php

4. Verify that you can add sitelinks[edit]

  1. Go to Special:SetSiteLink in your repo-wiki and try to link an existing Item (field "ID") to one of the above configured sites (field "Site ID") by providing an existing page on that wiki (field "Sitelink"). It should either work or give you a useful error message.
  2. On the page you added above, check that Direct access works by referencing a property of the Item in a parser function