Set the completed shelf into the wall. Clamp it to the wall stud, making sure that the front of the shelf is flush with the front of the wall board.
Drill pilot holes, counter-sink them, and then drive in screws, attaching the side of the shelf to the stud.
Note: You may need to use shims to keep the unit level and plumb.
