.TableOfContents

According to the docs it should be possible to put {{ .Page.TableOfContents }} on a page and the TOC should show up.

However, this does not seem to work, even when I create a shortcode it does not work. When I put it in a partial layout then it works. I would like to be able to choose the pages where I place the toc.

Is there a solution for this ?

You can not access ToC from shortcode (this is the chicken and the egg).

Use a page param toc=true or something. See the Hugo docs for an example.

Sorry, but do not understand how I would do this. Can you give an example, can’t find anything in the docs on how to do this

https://github.com/spf13/hugo/blob/master/docs/layouts/_default/single.html#L2

Thanks

Is there a way to control the levels the TOC is displaying ?
eg. only show h1 ?

Only via CSS. There is a thread about it in here somewhere.

You mean this thread, right.

yup that’s it

tks