A headframe is actually a frame structure placed on top, at the head, of a mining shaft. The structure is necessary to build an elevator into the mine, to hoist machinery, personnel, or materials. The elevator hangs on steel ropes in the shaft. The rope goes over the wheel in the top of the headframe to the engine, which pulls the elevator.
Alternative names: gallows frame, winding tower, hoist frame, pit frame, shafthead frame, headgear, headstock, poppethead.
The basic principle of an elevator is a cabin, a rope, a winch, and a motor which powers the winch. The winch is where the cable is stored, when the elevator is pulled up it fills, when it is lowered, the rope from the winch is uncoiled. A little more complicated is a simple idler pulley and two cabins. One cabin is on the upper ende while the other is on the lower end. By pulling the cable through the idler pulley the upper is lowered while the lower is pulled up. The main difference is the necessary energy: as the weight is the same on both sides, no energy is required for pulling the cabin.
So the main question is actually: why is there a frame? Why not placing the winch directly on top of the shaft, this is done with elevators in buildings. There are basically three reasons:
It is much rarer, but there are also systems where the engine is located at the top of the tower. In this case, it is called a winding tower. To protect the engine and the mechanics from wear and tear caused by the weather, they usually have walls. A winding tower, on the other hand, does not need walls; the rope is exposed to moisture in the shaft anyway and is kept rust-free by the constant movement.