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:

ComponentDescriptionGem nameGitLab projectUpstream project
gitlabMarkup renderer, depends on various other gemsgitlab-markupgitlab-org/gitlab-markupgithub/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 ModelGitaly Class
WikiGitlab::Git::Wiki
WikiPageGitlab::Git::WikiPage, Gitlab::Git::WikiPageVersion
Gitlab::Git::WikiFile

Only some data is persisted in the database:

ModelDescription
WikiPage::MetaMetadata for wiki pages
WikiPage::SlugCurrent and previous slugs of wiki pages
ProjectRepositoryGitaly storage data for project wikis
GroupWikiRepositoryGitaly 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.