The only proper and most safe way to run a generator is with a transfer switch. These switches should only be installed by an electrician.
Transfer switches have three selections.
It prevents you from having the generator and the utility power on at the same time. Which would mess up the wiring in your home. And when installed properly will prevent a backfeed to the utility lines which could prove fatal to lineman working. The utility transformer is a stepdown into your home but becomes a stepup when fed the other way.