Wikis development guidelines

Wiki functionality in GitLab uses Git repositories as the storage backend and is accessed from the Rails app through Gitaly RPC calls.

You can access wikis through:

Involved Gems

Some notable gems that are used for wikis are:

Component Description Gem name GitLab project Upstream project
gitlab Markup renderer, depends on various other gems gitlab-markup gitlab-org/gitlab-markup github/markup

Wiki rendering

When rendering wiki pages, we use a custom Banzai pipeline. This pipeline adds wiki-specific markup, such as the [[link]] syntax.

Model classes

The Wiki class is the main abstraction around a wiki repository. You must initialize it with a container, which can be either a Project or Group:

classDiagram
  Wiki --> ProjectWiki
  Wiki --> GroupWiki

  class Wiki {
    #container
    #repository
  }

  class ProjectWiki {
    #project → #container
  }

  class GroupWiki {
    #group → #container
  }

Some models wrap similar classes from Gitaly:

Rails Model Gitaly Class
Wiki Gitlab::Git::Wiki
WikiPage Gitlab::Git::WikiPage, Gitlab::Git::WikiPageVersion
Gitlab::Git::WikiFile

Only some data is persisted in the database:

Model Description
WikiPage::Meta Metadata for wiki pages
WikiPage::Slug Current and previous slugs of wiki pages
ProjectRepository Gitaly storage data for project wikis
GroupWikiRepository Gitaly storage data for group wikis

Attachments

The web UI uploads attachments through the REST API, which stores the files as commits in the wiki repository.