Configuration file

This article is intended for wiki administrators.

The main way to configure your Mojowiki instance is through the configuration file. It is located at the root of your wiki structure and is called config.json.

The file is generated automatically when you create a new wiki:

# Generate a new wiki
$ mojowiki serve best-wiki
...
# See what's inside
$ ls best-wiki
cache		config.json	static		wiki.git

The file is written in JSON, and it carries no comments. Every key, with its type, its default and what it does, is documented in the config.md file in the repository. Read that page before changing anything here.

Only the keys you care about

The defaults are applied first and the file is read over them, so a short file is a completely valid file. You do not have to write out every key:

{
  "WikiName": "My wiki",
  "URL": "https://wiki.example.com",
  "UseAuth": true
}

A key you leave out keeps its default. A key that does not exist is ignored.

Example

A fuller file, with the settings an ordinary wiki tends to change:

{
  "WikiName": "My wiki",
  "NaviTitleIcon": "🐑",
  "HomePage": "home",
  "UserPage": "u",
  "URL": "https://wiki.example.com",
  "UseAuth": true,
  "AllowRegistration": true
}

Editing from the admin panel

Everything in config.json can be changed at /admin/settings instead of by hand. A saved change takes effect at once, without a restart: the wiki name, the home page and the rest apply immediately, and turning authorisation on or off adds or removes the sign-in and admin pages as soon as you save.

Two things are not on that page:

  • The listen address. It belongs to the process, not the wiki: use -listen-addr or MOJOWIKI_LISTEN_ADDR.

  • Turning authorisation back on, once you have turned it off. With authorisation off there is no admin panel to reach. Set "UseAuth": true in config.json by hand, or run mojowiki create-admin, which enables it.

If the wiki directory is read-only, saving fails and says so; nothing is written.

Authorisation is on by default

UseAuth is true unless you turn it off, so a new wiki enforces rights from the first start: reading is open, editing needs an account. That means a new wiki has no administrator and you have to create one:

$ mojowiki create-admin alice /srv/wiki

The wiki says so in its log on every start until an administrator exists. If you want a wiki that anyone may edit without signing in, set "UseAuth": false.

Things to watch out for

  • JSON is strict. A trailing comma, a missing quote or a value in the wrong place stops the wiki from starting, and the error names the file. Check your edit with any JSON validator if it will not start.

  • Set URL. If it is left out it is derived from the address the server binds, and a wildcard address becomes localhost, which is useless in feeds and Open Graph tags.

  • The listen address is not in this file. It is set with -listen-addr or MOJOWIKI_LISTEN_ADDR, and defaults to 0.0.0.0:1737. A ListenAddr key here is rejected.

  • Lists are real lists. WhiteList is written as ["alice", "bob"], so a name containing a comma is no longer a problem.

Coming from config.ini

Earlier versions used config.ini. That file is ignored: the wiki writes a fresh config.json with the defaults and says so in the log. The settings did not change, only the format. The mapping is described at the end of config.md.