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/pwnable-kr-fd.md here:
https://gist.githubusercontent.com/heapcrash/ea47fddf52b157b01d3f34f78f708f01/raw/15000be3aee9793c9db51dc9da29921fb407db6b/example.md

And my config,toml is relatively bare:
https://gist.githubusercontent.com/heapcrash/cbb80b9d3074cb3680b247b9e5d0ee7f/raw/60fc779ee909604e47bb860d7369d76f936eea0e/config.toml

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.

[markup]
  [markup.tableOfContents]
    endLevel = 8
    startLevel = 1