How to get :toc: Table of Contents to work

I am a new user to Hugo, so please excuse my ignorance,

My understanding is that the default renders, GoldMark, will automatically pick on up :toc: to generate a Table Of Contents for a given blog post.

However, I’m having trouble with this. You can see my example content/posts/ here:

And my config,toml is relatively bare:

What do I need to do for a Table of Contents to be generated for each blog post?

You can create a shortcode for TOC and call it wherever you want in a post

your shortcode location should be layouts/shortcodes/toc.html and paste {{ .Page.TableOfContents }} this code in toc.html file.

then call it in a post like {{< toc >}}

Note that the default Hugo values for the toc renderer in Goldmark are somewhat erratic. It only renders level 2 and 3 markdown headings in the toc. You can see the defaults at Configure Markup | Hugo.

To render all headings (I usually like to start from level 1 headings but level 2 as the start is also a sane option), modify them like this in your config.toml.

    endLevel = 8
    startLevel = 1