# TOC inside shortcode?

**URL:** <https://discourse.gohugo.io/t/toc-inside-shortcode/17669>\
**Category:** support\
**Created:** [March 19, 2019, 1:15pm UTC](https://discourse.gohugo.io/t/toc-inside-shortcode/17669 "2019-03-19T13:15:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![omrllm](https://avatars.discourse-cdn.com/v4/letter/o/ed8c4c/32.png) [@omrllm](https://discourse.gohugo.io/u/omrllm)\
**Post date:** [March 19, 2019, 1:15pm UTC](https://discourse.gohugo.io/t/toc-inside-shortcode/17669/1 "2019-03-19T13:15:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![zwbetz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/zwbetz/32/16088_2.png) [@zwbetz](https://discourse.gohugo.io/u/zwbetz)\
**Post date:** [March 20, 2019, 4:34pm UTC](https://discourse.gohugo.io/t/toc-inside-shortcode/17669/2 "2019-03-20T16:34:48Z")

</div>

In your shortcode definition, try it like this

```nohighlight
{{ .Page.TableOfContents }}

```

---

<div class="post-metadata">

**Author:** ![omrllm](https://avatars.discourse-cdn.com/v4/letter/o/ed8c4c/32.png) [@omrllm](https://discourse.gohugo.io/u/omrllm)\
**Post date:** [March 21, 2019, 11:42am UTC](https://discourse.gohugo.io/t/toc-inside-shortcode/17669/3 "2019-03-21T11:42:50Z")

</div>

That works!

Thank you!

---

<div class="post-metadata">

**Author:** ![vistad](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/vistad/32/20509_2.png) [@vistad](https://discourse.gohugo.io/u/vistad)\
**Post date:** [July 3, 2020, 11:37am UTC](https://discourse.gohugo.io/t/toc-inside-shortcode/17669/4 "2020-07-03T11:37:35Z")

</div>

Hello @ [omrllm](https://discourse.gohugo.io/u/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.
