This is a specialized post that very few people will find useful. But since it's not something you can easily find by searching, I'll make it available to anyone else in my position.
I wanted to add a table of contents to a document in Pandoc, but without standalone mode - something that is not possible. However, you can just use a very minimalist template called something like blank.html:
That's it. Then this
pandoc -s file.md -o file.html --template=blank.html
is just as good as not using standalone mode.