I have a layout that includes content generated from the front matter. This layout generated content includes headings.
However, these headings are not included in the page’s Table of Contents.
How can I fix it so the headings which are part of the layout get included in the Table of Contents?
Thank you!
maiki
2
Share your code and we’ll let you know.
The layout looks something like this
<h1>Header</h1>
Abc...
<h2>Header 2</h2>
Abc...
<h2>Header 3</h2>
Abc...
{{ .Content }}
{{ .TableOfContents }}
The headers included in the content are shown in the table of contents. But the three headers in the layout aren’t included.
maiki
4
The .TableOfContents
gets it’s headings from a content file, not a template.
If your template is always the same, you might append your headings to the TOC, but you may want to rethink using the TOC altogether now. 
Would you be able to post an example of how to modify the Table of Contents object to programmatically add headings like we have here?
That would be super helpful. I can find references to it being possible, but I can’t find an example.