This article is from the Baby Proofing FAQ, by Sandra Smith, firstname.lastname@example.org with numerous contributions by others.
From: Steve Glassman
We made very simple (but effective) baby gates (or fences) with 2x4's and 1 inch
Cut 2 2x4 lengths equal to the width of the doorway. Drill 1 inch diameter
holes about 5 inches apart (measured from center of one hole to the center of
the next - 6 inches is too wide since it leaves a 5 inch gap between the bars).
The leftmost and rightmost holes should be only about 4 - 4.5 inches from the
ends or the end gaps will be too big.
Cut the dowels to 2 foot lengths. Assemble with one 2x4 on the bottom, one on
the top and the dowels in between.
Baby gates tend to be virtually permanent (from about 6 months old to ?). So
you can just nail the 2x4's to the wall.
The result is secure and looks pretty good (especially if you finish the 2x4's
We used the railing from a banister as the top of the gate, so that it looked a
little nicer. We also did a slightly fancier connection to the wall, just in
case we wanted to take it down temporarily (we haven't yet).
The only tricks are cutting the 2x4 lengths correctly for moldings at the base
of the wall, and adjusting for the width of the moldings when drilling the
holes for the dowels so that the dowels line up vertically. Measure carefully.