# Applying headings in shortcodes to the table of contents

**URL:** <https://discourse.gohugo.io/t/applying-headings-in-shortcodes-to-the-table-of-contents/32132>\
**Category:** Uncategorized\
**Created:** [April 2, 2021, 3:34pm UTC](https://discourse.gohugo.io/t/applying-headings-in-shortcodes-to-the-table-of-contents/32132 "2021-04-02T15:34:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucperkins](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/lucperkins/32/1280_2.png) [@lucperkins](https://discourse.gohugo.io/u/lucperkins)\
**Post date:** [April 2, 2021, 3:34pm UTC](https://discourse.gohugo.io/t/applying-headings-in-shortcodes-to-the-table-of-contents/32132/1 "2021-04-02T15:34:57Z")

</div>

I’m currently working on a project that requires a lot of re-using information on multiple pages via shortcodes. In some cases, that means pulling in structured data using `site.Data` and in other cases that means pulling in small bits of Markdown using `readFile`. The problem I’m running into is that the `TableOfContents` doesn’t seem “aware” of anything that’s introduced into the page via shortcodes, which means that none of the headers inside shortcodes end up in the table of contents. I’m really hoping to avoid the only workaround I can think of, which is using `Scratch` or some other mechanism to build the TOC by hand.

Is there a way around this? Perhaps a configuration parameter I’m not seeing in the docs?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [April 2, 2021, 7:04pm UTC](https://discourse.gohugo.io/t/applying-headings-in-shortcodes-to-the-table-of-contents/32132/2 "2021-04-02T19:04:29Z")

</div>

Call the shortcode like this `{{% foo %}}` instead of this `{{< foo >}}`.

See [https://gohugo.io/content-management/shortcodes/#shortcodes-with-markdown](https://gohugo.io/content-management/shortcodes/#shortcodes-with-markdown).

> Shortcodes using the `%` as the outer-most delimiter will now be fully rendered when sent to the content renderer. They can be part of the generated table of contents, footnotes, etc.

If your shortcode includes HTML, you will have to change your configuration setttings:

```auto
[markup.goldmark.renderer]
unsafe = true

```

Otherwise the HTML will be rendered as `<!-- raw HTML omitted -->`.
