A flexible measuring tape as is customary for sewing is best suited to measure the head circumference. In case of need, however, a piece of twine can also be used (these can be simply lead around the head and then measure with a normal measuring tape /ruler).
Then face a mirror. Fix the front end of the measuring tape in the middle of the forehead & put it just above the ears once around the head. The tape measure should just be as thight as you want your hat to be.
If you want to be safe, you can add an extra 0,5 cm-1cm.