TOC inside shortcode?

Same problem

I have {{< myshortcode >}} inside the markdown file where I want the table of contents to appear.
Inside layouts/shortcodes/myshortcode.html I have {{ .TableOfContents }}

But it gives me an error.

Is there an easy way to implement {{ .TableOfContents }} inside a markdown file?

In your shortcode definition, try it like this

{{ .Page.TableOfContents }}
7 Likes

That works!

Thank you!

1 Like

Hello @ omrllm, can you explain how you implemented your table of contents?
Does your TOC outputs certain tags from articles.md frontmatter?
Can you show us some samples?
Thank you.