As suggested in "Wood Fences" (page 30), a gate's hinge post should be buried the greater of 3' or one-third of its length deep in the ground and anchored in packed dirt.
The most sturdy gates have a rectangular frame with a diagonal brace running from the top of the latch post to the bottom of the hinge post.
Easiest to install and adjust are eye and pintle sets that simply screw into pilot holes drilled into the gate's hinge-side stile and hinge post.
At top, bottom, and middle of the stile, insert 3" shingle splits from each side, between stile and post; push together so that the stile is immobilized and wedged tight parallel to the hinge post.
If it does, push the vertical post back in position, then use "L" brackets and screws to reconnect this hinge post
to the horizontal 2x4 as shown.