The first step is to decide on the dimensions of the gate. Once you know the height and width, and thickness of the wood (or other material) you're going to build it with, you can build the frame, minus the crosspiece. Then decide what type of diagonal brace you want.
Now it's time to do math! Yay! Fortunately, we can get all the dimensions we need with just three equations: the Pythagorean theorem, SOH CAH TOA, and the law of sines, since we know the inner dimensions of the gate frame and the thickness of the wood we're planning to use for the brace (e.g., 1.5" for the thin side of a 2 x 4).
We've also compiled this information into a handy Excel-based calculator, free for download here. Let us know if you have any suggestions to improve it!
How do you size the diagonal braces for your gates, etc.? What was the last thing you attached a gate to? Let us know in the comments section below!