17

I am a big fan of the __TOC__ that creates a table of content on a Wikimedia page.

Whenever you write things like this on a Wikimedia page:

This is a page for my project

## Credits ##

bla bla

## License ##

bla bla

__TOC_ automagically creates a table of content that allows you to navigate through inner links of the page.

I noticed that this is somehow possible in GitHub wiki pages: How do I create some kind of table of content in GitHub wiki? by using different tricks.

However, I miss this feature in GitLab wiki pages. Does it provide such functionality?

fedorqui
  • 252,262
  • 96
  • 511
  • 570

3 Answers3

30

So this exists! I finally found a Merge Request in in the GitLab Community Edition: Replace Gollum [[_TOC_]] tag with result of TableOfContentsFilter

As its name describes, to have a table of contents you need to write the following:

[[_TOC_]]

All together, you can write something like:

This is a page for my project

[[_TOC_]]

## Credits

bla bla

## License

bla bla

and will show like this:

enter image description here

This is available from the GitLab 8.6 release as described in its milestone.

fedorqui
  • 252,262
  • 96
  • 511
  • 570
  • This no longer appears to work. has it been replaced? – Jwely Dec 12 '19 at 21:02
  • @Jwely what version of GitLab are you using? It works well in my 11.3. You can also try what is described in the [Markdown Guide by GitLB](https://about.gitlab.com/handbook/engineering/technical-writing/markdown-guide/#table-of-contents-toc) – fedorqui Dec 13 '19 at 09:08
  • The error was mine. I presumed this would render online for a top level project README.md, when it is only intended to work when using the wiki features of gitlab. – Jwely Dec 13 '19 at 15:38
  • @Jwely ah right, it makes sense. There are some requests to have this in place: https://gitlab.com/gitlab-org/gitlab/issues/21901 – fedorqui Dec 14 '19 at 19:16
0

Should be something like this

 ##### Table of Contents  
[1.-First Topic](#first-topic)
[2.-Second Topic](#second-topic) 
[3.-Third Topic](#third_topic)

And then you will reference each on the same page by using

 <a name="first-topic"/>
 <a name="second-topic"/>
 <a name="third-topic"/>
  • 2
    Note, though, that `[[_TOC_]]` creates this content automatically, which is what I was asking for in the question. We always have time to make it manually, but automagically is better :) – fedorqui Oct 03 '19 at 15:56
0

Try using {{< toc >}} on top of the document. It should automatically generate the TOC for you.

  • where did you try it? In my GitLab 11.3.3-ee it does not work, while [`[[_TOC_]]`](https://stackoverflow.com/a/47154662/1983854) does – fedorqui Dec 15 '20 at 08:11