Toggle TOC

I’m writing some markdown and I’ve decided for this blog post, since it’s getting a little long, I need a Table of Contents (TOC).

Though reading https://gohugo.io/content-management/toc/ … it would appear I need to apply a TOC system wide. How do I do it for just one post? Has someone got an example please?

System wide…? I don’t get it.

Well, you could simply make it conditional based on a custom param, like:

{{ if .Params.toc }}
  {{ .TableOfContents }}
{{ end }}

And then add toc: true (assuming it’s YAML) to the front matter of the chosen post.

1 Like

Site wide? Sorry

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.