HUGO

.TableOfContents without #TableOfContents ID?

So, IDs need to be unique and I need to call the Table of Contents more than once (for mobile and for desktop, both of which are in different divs). I would just expect an output of bare <ul>, <li>, and <a>.

Is it possible to fix this with a template for the ToC?

It is possible to fix by loading the .TableOfContents variable and modifying it (remove the ID).

{{ replace .Page.TableOfContents "nav id=\"TableOfContents\"" "div class=\"toc\"" | safeHTML }}

This worked for me. I needed to escape the characters.

Thank you a lot for the quick help!

1 Like