7
  1. I "pulled" the wiki repository of my project.
  2. Created "_sidebar.md" file.
  3. Git add
  4. Git commit
  5. Pushed the changes to GitLab.
  6. Loaded the Wiki page of my project in Google Chrome's incognito mode.
  7. Custom sidebar is not rendered.

I refreshed many times. No luck.

This is the content of my _sidebar.md:

0. [Home](home)
1. [Page 1](page-1)
2. [Page 2](page-2)

Any ideas?

Rory O'Kane
  • 29,210
  • 11
  • 96
  • 131
honor
  • 7,378
  • 10
  • 48
  • 76

3 Answers3

3

That should be working now, with GitLab 11.2 (August 22nd, 2018), thanks to jsooter.

See "Custom Wiki sidebar":

When utilizing a Wiki in your GitLab project for extended documentation, the right sidebar shows a hierarchical table of contents of your Wiki page structure by default.
There are cases, however, where you may want to provide additional content, extending this set of automatically listed pages.

With GitLab 11.2, we introduce an option to override the generated table of contents via your own custom sidebar. By adding a _sidebar Wiki page, maintainers gain full freedom to define an individual Wiki sidebar based on GitLab Flavored Markdown.

https://about.gitlab.com/images/11_2/wiki-custom-sidebar.png


You can also use an editor to kale sure the sidebar is correct: see GitLab 13.8 (January 2021).

Quickly edit Wiki's sidebar

Creating a Markdown file named _sidebar in the Wiki will use the contents of that file to generate a custom sidebar navigation menu for your project.
Editing this file, however, was tricky as there was nowhere in the interface to open _sidebar again.

Thanks to a wonderful community contribution from GitLab user Frank Li, starting in GitLab 13.8 there is now an Edit sidebar button in the top right of the Wiki page.

Clicking this button will automatically create the _sidebar file if it doesn’t already exist and open it in the page editor.
With this quick access, it is more intuitive to create and easier to maintain your custom Wiki navigation.

See Documentation and Issue.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
3

It works now as VonC explained. However, you don't need to clone your repository.

Simply create a new page on GitLab GUI called _sidebar. You may access it by your-repository/wikis/_sidebar or create an edit link in your sidebar:

0. [Home](home)
1. [Page 1](page-1)
2. [Page 2](page-2)

[Edit sidebar](/_sidebar/edit)
Adam
  • 25,960
  • 22
  • 158
  • 247
3

I found it frustrating to keep updating the sidebar or table of content by hand. So I wrote a simple code that prints out a list in the correct format so you won't need to write it by hand:

import os
ignore_list = [".git", ".idea", "create_table_of_content.py"]
spaces = "    "


def get_all_files_and_directories(path, depth):
    spaces_tmp = spaces*depth
    file_list = os.listdir(path)
    for f in file_list:
        if f in ignore_list:
            continue
        if os.path.isdir(path+"/"+f):
            print(f'{spaces_tmp}- {f}')
            get_all_files_and_directories(path+"/"+f, depth+1)
        elif f.split(".")[-1] == "md":
            print(f'{spaces_tmp}- [{f.split(".")[0]}]({f})')
    return


if __name__ == '__main__':
    c = os.getcwd()
    get_all_files_and_directories(c, 0)

Just run it at the root of the wiki repo.

Sample output:

- The-Code is a directory
    - editor-applications is a directory
        - [edit_hosts_file](edit_hosts_file.ps1.md)
        - [mount_logs_dir](mount_logs_dir.ps1.md)
        - [main-editor-app](main-editor-app.ps1.md)
        - [setup_tasks](setup_tasks.ps1.md)
- [home](home.md)
- [Logging](Logging.md)
- Execution is a directory
    - [User-Data](User-Data.md)
    - [General](General.md)
- [File-Structure](File-Structure.md)
- [Running-Manually](Running-Manually.md)
- [About](About.md)

This should make it easier to maintain.

Edit

I found this repo https://github.com/ekalinin/github-markdown-toc with a tool that creates a TOC by titles. Personally I think it is better to create a single page with TOC rather then a multi page wiki.

nirlevywm
  • 86
  • 5