Hugo new command scrambles front matter

I spent some time working out a good set of archetypes, with menu entries placed last.
However, "hugo new " scrambles the order of the fields badly.

For example, I have a review archetype:

+++
tags = [“review”, “opinion”]
categories = [“reviews”]
type = “page”
[menu.main]
weight = 99
name = "menu name"
parent=“parentid”
+++

If I run “hugo new page/writing/new_story.md” and then look at the file, it looks like this:

+++

categories
= [“reviews”, ]
parent = "parentid’
[menu.main]
type = "page"
tags = [“review”, “opinion”]

+++

Sometimes it is worse.

Any ideas?

This doesn’t look good and thanks for reporting … We will fix this, but your current workaround is to use YAML (or JSON) front matter.

https://github.com/spf13/hugo/issues/2745

Note that if you are running Hugo 0.17, it may be worth it to test the latest development version. I haven’t checked, but there have been some related TOML fixes.