My hat collection
I also hang my hats, using two disc magnets
S-10-05-N
each.
Depending on how much the hat weighs, it may need slightly stronger magnets.
And of course, before starting this project, you need to make sure the doorframe has ferromagnetic components.