As Nidum wrote; A wind-vane on the head, generates an error signal, that controls a servo-motor to drive the windmill head into the wind.
For historical systems, google images; 'windmill fantail'
Tower mills had high fantails at the back, coupled through reduction gears or belts to a pinion running on a fixed azimuth bull gear.
Post mills were walked around when needed with a tail-pole or the rear steps. Some post mills had fantails on the tail-pole or the rear steps that turned a wheel on the ground to keep the mill facing into the wind.
Small wind pumps used on farms offset the horizontal turbine axis sideways from the vertical azimuth axis. The tail is spring loaded from the head so as the wind increases, the turbine blades gradually turn to be side on to the wind. That limits the top speed of the turbine and so prevents destruction in wind storms. When the tail mechanism fails due to lack of regular service, the turbine blades are thrown, until unbalance breaks the shaft, whereupon the damaged turbine wheel heads off across the farm.