# H headers do not fall into the TOC Shortcode

**URL:** <https://discourse.gohugo.io/t/h-headers-do-not-fall-into-the-toc-shortcode/32008>\
**Category:** support\
**Created:** [March 27, 2021, 6:22pm UTC](https://discourse.gohugo.io/t/h-headers-do-not-fall-into-the-toc-shortcode/32008 "2021-03-27T18:22:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![uPagge](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/upagge/32/12579_2.png) [@uPagge](https://discourse.gohugo.io/u/uPagge)\
**Post date:** [March 27, 2021, 6:22pm UTC](https://discourse.gohugo.io/t/h-headers-do-not-fall-into-the-toc-shortcode/32008/1 "2021-03-27T18:22:13Z")

</div>

I figure out how to add H headers to the TOC

```
{{% context %}}

## Toc Test

{{% /context %}}

```

In this form, everything works, but if I do this

```
{{% context %}}
{{% context %}}

## Toc Test

{{% /context %}}
{{% /context %}}

```

The header misses the TOC

My simplified shortcode looks like this

```
<section>
{{ .Inner }}
</section>
```

---

<div class="post-metadata">

**Author:** ![uPagge](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/upagge/32/12579_2.png) [@uPagge](https://discourse.gohugo.io/u/uPagge)\
**Post date:** [March 27, 2021, 6:42pm UTC](https://discourse.gohugo.io/t/h-headers-do-not-fall-into-the-toc-shortcode/32008/2 "2021-03-27T18:42:28Z")

</div>

I found a strange pattern. If you do like this

```auto
{{% context %}}
{{< context >}}

## Toc Test

{{< /context >}}
{{% /context %}}

```

Then everything works. What?

What’s the difference between using ‘\<’ or ‘%’?

---

<div class="post-metadata">

**Author:** ![uPagge](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/upagge/32/12579_2.png) [@uPagge](https://discourse.gohugo.io/u/uPagge)\
**Post date:** [March 27, 2021, 6:44pm UTC](https://discourse.gohugo.io/t/h-headers-do-not-fall-into-the-toc-shortcode/32008/3 "2021-03-27T18:44:27Z")

</div>

But it doesn’t work like that anymore. What’s going on here anyway?

```
{{< context >}}
{{% context %}}

## Toc Test

{{% /context %}}
{{< /context >}}
```

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 27, 2021, 7:47pm UTC](https://discourse.gohugo.io/t/h-headers-do-not-fall-into-the-toc-shortcode/32008/4 "2021-03-27T19:47:31Z")

</div>

> [@uPagge](#):
>
> `{{%`

Means “process the inner content as Markdown”.

`{{<` means leave the inner content as is.

This will however have different meaning for the outer-most shortcode tag. If you use `{{%` somewhere nested, that shortcode’s inner content will be rendered as Markdown on its own – which is the reason it does not show up in the outer ToC.

---

<div class="post-metadata">

**Author:** ![uPagge](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/upagge/32/12579_2.png) [@uPagge](https://discourse.gohugo.io/u/uPagge)\
**Post date:** [March 27, 2021, 9:19pm UTC](https://discourse.gohugo.io/t/h-headers-do-not-fall-into-the-toc-shortcode/32008/6 "2021-03-27T21:19:36Z")

</div>

That is, there is no way to do it the way I want, no? Only use such a construction?

```
{{% context%}}
{{<context>}}
```

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 27, 2021, 9:46pm UTC](https://discourse.gohugo.io/t/h-headers-do-not-fall-into-the-toc-shortcode/32008/7 "2021-03-27T21:46:14Z")

</div>

> [@uPagge](#):
>
> ```auto
> <section>
> {{ .Inner }}
> </section>
> 
> ```

To put your question into its original perspecitve: There is no way to tell Goldmark (the Markdown renderer we use as default) that what’s inside the `section` is Markdown.

But you can generate this ToC client side.

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [March 28, 2021, 10:05am UTC](https://discourse.gohugo.io/t/h-headers-do-not-fall-into-the-toc-shortcode/32008/8 "2021-03-28T10:05:51Z")

</div>

> [@uPagge](#):
>
> That is, there is no way to do it the way I want, no? Only use such a construction?
> 
> ```auto
> {{% context%}}
> {{<context>}}
> 
> ```

That’s what I would call “a dirty hack”. I think you are trying to do something weird inside of the context shortcode.

1. The ToC is working with headers, why would you have the need to nest headers?
2. {{% means “process markdown in what you return” as an order to Hugo. Are you aware, that it can only return processed markdown and putting it inside of each other ends it up in a loop that processes because it needs to process before the other once can process? Process?

I would say this is probably more or less something that you need to work through with a `.Scratch` or maybe take a step or two back and rethink the whole construction. Because see 1. If it’s about ToC there is probably no need to nest headings or whatever happens in that shortcode.

---

<div class="post-metadata">

**Author:** ![uPagge](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/upagge/32/12579_2.png) [@uPagge](https://discourse.gohugo.io/u/uPagge)\
**Post date:** [March 31, 2021, 4:47pm UTC](https://discourse.gohugo.io/t/h-headers-do-not-fall-into-the-toc-shortcode/32008/9 "2021-03-31T16:47:10Z")

</div>

Nothing weird, just this kind of layout and markup. Sometimes shortcodes overlap!

 ![изображение](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/7/797e53041fb5a61260974f8cce31a39ff33729c3.png)

To make such a break visual, I put the chapter in a shortcode
