# TOC ne fonctionne pas

**URL:** <https://discourse.gohugo.io/t/toc-ne-fonctionne-pas/52137>\
**Category:** support\
**Created:** [October 26, 2024, 8:35am UTC](https://discourse.gohugo.io/t/toc-ne-fonctionne-pas/52137 "2024-10-26T08:35:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hugo3](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hugo3/32/21478_2.png) [@Hugo3](https://discourse.gohugo.io/u/Hugo3)\
**Post date:** [October 26, 2024, 8:35am UTC](https://discourse.gohugo.io/t/toc-ne-fonctionne-pas/52137/1 "2024-10-26T08:35:35Z")

</div>

Hello,  
I know that this subject has already been discussed at length on this forum but despite all the answers I can’t find a solution.  
With my single template the toc is not generated.  
Everything works except the toc.

My single template:

```auto
{{ define "main" }}
<div class="row justify-content-center gx-0">
    <!-- Menu de l'article -->
    <div class="col-lg-2 d-none d-lg-block">
        <div class="card shadow-sm sticky-top" style="top: 100px;">
            <div class="card-body">
                <h5 class="card-title">Sommaire</h5>
                {{ .TableOfContents }}
            </div>
        </div>
    </div>

    <!-- Contenu de l'article -->
    <div class="col-lg-6">
        <div class="px-4 text-center">
            <i class="fa-solid fa-{{ .Params.icon }}"></i>
            <h1 class="display-4 mb-2 fw-bold text-body-emphasis">{{ .Title }}</h1>
            <div class="my-4 d-flex justify-content-evenly">
                <div>
                    <i class="fa-regular fa-clock"></i> {{ .Date.Format "02 janvier 2006" }} &#x2022; {{ .Date.Format
                    "15:04" }}
                </div>
                <div>
                    <img src="https://app.ugosign.com/images/hugo.jpg" alt="Photo de Hugo LEROUX" class="rounded-circle"
                        style="width: 30px; height: 30px;">
                    <span class="ms-1">{{ .Params.Author }}</span>
                </div>
                <div>
                    <i class="fa-regular fa-folder-closed"></i>
                    {{ range .Params.categories }}
                    <a href="{{ " /categories/" | relLangURL }}{{ . | urlize }}">{{ . }}</a>
                    {{ end }}
                </div>
            </div>
            <h4 class="mb-4">{{ .Params.Intro }}</h4>
            {{ if .Params.Image }}
            <div class="container px-5">
                <img src="/images/blog/{{ .Params.Image }}" class="img-fluid border rounded-3 mb-4" alt="Example image"
                    loading="lazy">
            </div>
            {{ end }}
        </div>
        <div class="container mt-3">
            {{ .Content }}
            {{ $taxonomy := "tags" }}
            {{ with .Param $taxonomy }}
            {{ range $index, $tag := . }}
            {{ with $.Site.GetPage (printf "/%s/%s" $taxonomy $tag) -}}
            <a href="{{ .Permalink }}" class="btn btn-outline-primary">
                <i class="fa-solid fa-hashtag fa-fw ms-2"></i>
                {{ $tag | urlize }}
            </a>
            {{- end -}}
            {{- end -}}
            {{ end }}
        </div>
    </div>
</div>
{{ end }}

```

My post:

```auto
---
title: "Les 6 fonctionnalités clés de la signature électronique pour les coachs d'entreprise"
intro: "Découvrez comment la signature électronique aide les coachs en entreprise à accélérer leur activité."
summary: "Découvrez comment la signature électronique aide les coachs en entreprise à accélérer leur activité."
description: "Les 6 fonctionnalités clés utile pour les coachs d'entreprise offertes par Ugosign"
date: 2024-10-02T10:32:45+01:00
draft: false
author: "Hugo LEROUX"
image: "6-fonctionnalites-coach-entreprise.webp"
altImage: "6 features pour les coachs en entreprise - Ugosign"
toc: true
categories:
- Signature électronique
tags:
- Business
---
<p>...</p>
<h2>1. Title A</h2>
<p>...</p>
<h2>2. Title B</h2>
<p>...</p>
<h2>3. Title C</h2>
<h2>Conclusion</h2>
<p>...</p>

```

Version:

```auto
hugo v0.136.5-46cccb021bc6425455f4eec093f5cc4a32f1d12c+extended linux/amd64 BuildDate=2024-10-24T12:26:27Z VendorInfo=gohugoio

```

Thanks

---

<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:** [October 26, 2024, 3:33pm UTC](https://discourse.gohugo.io/t/toc-ne-fonctionne-pas/52137/2 "2024-10-26T15:33:02Z")

</div>

[https://gohugo.io/methods/page/tableofcontents/](https://gohugo.io/methods/page/tableofcontents/)

> The `TableOfContents` method on a `Page` object returns an ordered or unordered list of the Markdown [ATX](https://spec.commonmark.org/0.30/#atx-headings) and [setext](https://spec.commonmark.org/0.30/#setext-headings) headings within the page content.

Or to put it another way, it doesn’t work with HTML content.

---

<div class="post-metadata">

**Author:** ![jerrychan7](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jerrychan7/32/23203_2.png) [@jerrychan7](https://discourse.gohugo.io/u/jerrychan7)\
**Post date:** [October 26, 2024, 5:15pm UTC](https://discourse.gohugo.io/t/toc-ne-fonctionne-pas/52137/3 "2024-10-26T17:15:24Z")

</div>

I wrote a template library to generate the correct and intuitive table of contents (ToC).  
[https://github.com/jerrychan7/hugoPerfectToC](https://github.com/jerrychan7/hugoPerfectToC)

Every `h1`~`h6` with an `id` attribute will be treated as a heading to be put into the ToC.

The downside is that parsing is time-consuming, and I am trying to optimize it.

---

<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:** [October 26, 2024, 7:14pm UTC](https://discourse.gohugo.io/t/toc-ne-fonctionne-pas/52137/4 "2024-10-26T19:14:03Z")

</div>

Or just use tocbot.js.
