Measure the gate opening, and purchase a gate piece that fits in the opening. The gate should fit in the opening with about 1/2 inch of space to spare, since the wood or metal can expand or contract with the elements.
Place the gate’s hinges on the fence post where you wish to attach the gate, and use a pencil to trace the bolt holes in the hinges. Drill pilot holes into the post where you marked, replace the hinge and drive the bolts into the pilot holes.
Hold the gate up to the hinges, and mark the locations of the bolt holes, using a helper to either hold the gate or mark the location of the holes. Drill pilot holes into the gate, and then tighten the bolts through the hinge and into the gate.
Position the gate spring, and mark the location of the screw holes. If the gate hinges sit on the left side of the gate, position the top of the spring to the gate and the bottom to the fence post. If the hinges sit on the right side, position the top of the spring on the post and the bottom on the gate.
Drill holes where you marked the spring’s screw holes. Replace the spring, and drive the screws into the pilot holes until the spring sits on the gate without moving. Position the latch pieces onto the gate and the fence post on the end without the hinges, and mark the location of the screw holes. Drill pilot holes, and then drive the screws through the latch pieces and into the pilot holes.