Wikibase/Installation/Advanced configuration

Introduction
This page describes advanced configuration for Wikibase's Client and Repository. If you haven't yet installed Wikibase, first consult the installation instructions.

Making changes to the client and repository configurations involves adding or changing or  lines (respectively) in the MediaWiki  file. This document covers only some options; for an exhaustive list, consult [ https://doc.wikimedia.org/Wikibase/master/php/docs_topics_options.html full documentation] (defaults: and  ).

Note that the prefix "wg" in is distinct from that of other extensions, which may use the prefix. The difference is important; your configuration will fail if you use a different prefix.

The parameters you set in override those found in the aforementioned files. Place any configuration settings you wish to override at the bottom of your file.

Example:

The line above sets the parameter of the Wikibase Repository (because  ) to the value.

Using only the client or the repository
Under some circumstances you may wish to use only the client or only the repository code.

Repository only
Versions 1.36 and above use extension registration:

Use the snippet below only if using versions below 1.36:

These configurations assume that your interwiki prefixes are and. Adjust as needed.

Note that wraps all the Wikibase repository configurations. See defaults in Wikibase.default.php.

Client only
Versions 1.36 and above use extension registration:

For another lang-wiki client, like Farsi, change the siteGlobalID to:

Use the snippet below only if using versions below 1.36:

You can look also the [ https://doc.wikimedia.org/Wikibase/master/php/docs_topics_options.html official complete description of the configurations options].

Note that wraps all the Wikibase client configurations. See defaults in WikibaseClient.default.php.

Define links for external identifiers
In order to add links for external identifiers in the main interface (as seen in this Wikidata example Q85#P214 and config P214#P1630):
 * 1) Create a property of type " String " (just like the property "formatter URL" in Wikidata).  The property that we are creating in this step will be the one used for storing the link formatter in other properties (e.g. usage of "formatter URL" in "VIAF ID").  Properties that use this property should be of type "External identifier".
 * 2) Get the ID of the property we created in the previous step (e.g.,  ).
 * 3) Configure in  :
 * 4) If adding the setting does not work on its own, run the following command
 * 5) Now users can use this property (in the example above P5) in properties whose type is "External Identifier".  The value must contain  in the URL formatter (e.g.  ),  will then be replaced by the identifier provided in the items that use the property that we set in the option.

Canonical URIs can be similarly configured in RDF dumps (prefixes wdtn:, psn:, pqn:, prn:), as seen on Wikidata with the property P1921 and used on the property P214#P1921). The configuration is similar to the parameter.

propertyOrderUrl
 propertyOrderUrl  allows custom ordering of properties using the LUA function as explained in Manual:Interface/Wikibase-SortedProperties

statementSections
 statementSections  allows a Wikibase administrator to customise statement display and grouping in Wikibase.

In LocalSettings.php, define with separate sections for each wiki on your instance. For identifiers and constraints, you can define a which filters certain elements out into their own section.

The syntax options for and  are:
 * &mdash; no elements are placed in a separate section
 * &mdash; elements with the specified data type/s appear in a separate section
 * &mdash; specify the data type/s to filter on
 * &mdash; elements with the specified property/ies appear in a separate section
 * &mdash; specify the property/ies to filter on

For instance, to replicate how Wikidata separates External identifiers from the rest of its properties, set: You can customise the name of the label using the page.

See also:
 * A Phabricator ticket requesting statement sections
 * Wikidata's own config
 * Example from the Wikibase code repo

Available configuration settings
All available configuration settings are noted in the [ https://doc.wikimedia.org/Wikibase/master/php/docs_topics_options.html master configuration document].

Maintenance scripts
Wikibase provides a few maintenance scripts which can be found in the subdirectory. Wikibase must be installed in MediaWiki's extensions directory,. If it's installed elsewhere, you can set the environment variable to the path of your MediaWiki installation and the scripts will use it.

Repo
A common way to set the environment for scripts called in cron jobs:

populateSitesTable.php
This script will load the wiki matrix from meta.wikimedia.org and use that information to populate the local table. This provides Wikibase with the information it needs to connect to other wikis, such as for the purpose of suggesting or normalising page titles when creating site links.

From the MediaWiki install folder, run:

To insert a new Wikibase client without using the wiki matrix, see Manual:Sites table.

dispatchChanges.php
This script updates the client wiki's local items cache.

1. Provide the script with the information it needs about the client wiki databases.

LocalSettings.php:

2. Run the dispatch changes script.

Note that this script performs the synchronisation; the repo and the client will remain in sync only so long as this script is running.

pruneChanges.php
This script allows you to prune the Wikibase changes table. When run with no parameters, it will delete all changes older than 7 days. You may specify the flag for periods of other lengths:

Features and usage
After Wikibase is installed, interlanguage links are automatically obtained from the repo and added to client wiki pages as long as the polling script is running. The extension then sorts the links (as defined by the local wiki), displays them and saves them to the database exactly as they are defined on the page. The extension is robust and retains existing links when the central wiki is down.

By default the extension works only in the main namespace, but this can be changed using the [ https://doc.wikimedia.org/Wikibase/master/php/docs_topics_entitysources.html namespaces] configuration option.

Mixing Wikidata and local interlanguage links
The extension doesn't affect how interlanguage links work; they can be used in parallel with the extension. There are several use cases:


 * Links on pages in namespaces not configured to use the extension will work as if the extension were not installed.
 * If you want to add links in addition to the links stored in Wikidata, simply add new links in wikitext; your links and the Wikidata links will be displayed together.
 * To exclude one or more Wikidata links, use noexternallanglinks with the desired language(s). Other links will work normally.
 * To supersede one or more Wikidata links, use noexternallanglinks and add the new links in wikitext.
 * To turn off Wikidata links altogether, use noexternallanglinks on its own. Links you provide will work as if the extension were not installed.

noexternallanglinks
is a magic word and a parser function which can turn this extension off for a specific page, or suppress some of the interlanguage links produced by the extension.

When used on its own, Wikibase is effectively disabled on the given page. Only interlanguage links present in the wikitext are used. The word works the same when used as a function, with an asterisk: (the asterisk "matches" all the languages).

When invoked as a function with parameters, links to the specified languages will be removed. For example, removes links to French and Indonesian languages. You may also invoke the function more than once:. It is safe to remove links to languages that don't exist.

Data transclusion
WikibaseClient allows data inclusion from the Wikibase repo using the parser function along with Lua.


 * Lua
 * Lua documentation


 * Parser functions
 * Lookup by property ID (e.g., P2), to include data from a Wikibase item connected by sitelink. For example,.
 * Lookup by property label. For example,.
 * With arbitrary access enabled, it can be applied to any item. For example,.
 * In addition to, which outputs linked wikitext, you can use  , which outputs unlinked labels.
 * See How to use data on Wikimedia projects for further documentation.

Other projects sidebar

 * See also Interproject links interface for the current status for Wikimedia projects.

The configuration option creates an "Other projects" sidebar section with links to other projects from the item linked to the current page. It currently supports exactly one link per project and does not yet override links in wikitext using a parser function (though current JavaScript hacks may be easily adapted).

Configuration sample (links will be displayed in the order specified):

The sidebar's id is "wikibase-otherprojects". You can use it to customise the section's position in the sidebar using Sidebar.

Each link has a the label containing the i18n messages " wikibase-otherprojects- ID " with  ID  the id of the linked site group (like " wikipedia ", " wikisource " or " commons ").

Sample page: Village pump.

commaseparatedlist
is a parser function that can be used in edit summaries for text formatting. It returns its list of arguments separated by the given language's proper separator. For example, results in word1, word2, word3.

Enabling sitelinks
Sitelinks are special links with a site and a title, linking 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 allow referencing an Item's property on the linked page in the client wiki, a feature known as Direct access.

Configuring your sitelink groups
First, consider how to group the client wikis you want to see in your sitelinks area for the Items in your repo wiki.

Defining custom groups
In your repo wiki, replace the content of in  with the groups you would like to see there.

For example, consider the following line in :

This would create three groups in the Item page's sitelinks box:


 * the standard defined for the global Wikipedia sites
 * two custom wiki groups (here named and  )

The names defined here will relate to the field in the   table, as specified below.

In your client wiki, add a similar configuration line with your :

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

Localise your groups
To show the correct heading for your groups, you must create the page with the desired heading as text.

You can create subpages to set headings for different languages, e.g., create to create a German heading.

Add the wikis to the sites table
In order to add sitelinks to Items in your repo wiki, you must add the client wikis to the sites table. Group names must match the group names you added to your configuration. Following the example above, you would have one or more sites with and  as text in the  field.

You must set both the file path and the page path, and each must include the placeholder.

Example
To add your wiki (with an id ending with ) to the  group , run:

Be sure to do this on the repo wiki and all client wikis so that the "Add links" functionality in the other languages section works correctly.

For further details on how to add sites to the table, please see these instructions.

Inform the repo wiki of the other client wiki databases
localClientDatabases &mdash; An array of locally accessible client databases, for use by the change dispatching mechanism. This setting specifies which wikis to directly push changes to. It must be specified either as an associative array (mapping global site IDs to logical database names) or as a list of databases (if the database names match the site IDs). The default is an empty array, indicating no local client databases.

Verify that you can add sitelinks

 * 1) Go to the  page in your repo wiki and try to link an existing Item (field " ID ") to one of the sites configured above (field " Site ID ") by specifying an existing page on that wiki (field " Sitelink ").  If it fails, it should provide 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.

There are no sites I can link pages to in an item.
One or more of the following may help: