Include Template Elements In Table Of Contents

I’ve added a table of Contents to my template and it works great. H2 and H3 are in the TOC as expected. In my case, I have a section of the single page template that should also be added as the last item in the Table of Contents. The content for this last section is not defined in the Mark Down content - only in the template.

Is there a way to add TOC entries that are not defined in Mark Down?


You’ll need to use something like tocbot.js instead of Hugo’s .TableOfContents method.