Hang your hat on the hat rack.

Literal

Hat [object-を] hat-hook [on-に] hang-[soft-command-なさい]

帽子掛け is a transparent compound: 帽子 (hat) + 掛け (the stem of 掛ける, 'to hang') = 'hat-hanging-thing' = hat rack. に marks the rack as the location where the hat will rest after the hanging.