It all depends.
where you live
your skill
local laws
and your own safety/ access decisions
"They" always say the shotgun is the best for the non expert....fairly quick to learn and understand, do well enough to hit, does the job, not overpenetrative.
A handgun is 'handy'. It requires some skill, though I wouldn't say you'd be defensless if you brought it home from the store the same day you were robbed.... then you get into wheel gun vs semiauto,
There is a great argument for a short, handy carbine. Like,,,the much mocked M1 Carbine, or Marlin Camp nine
IN the end, the weapon, the tool you are most comfortable with, the one that fits you, is the one to have. I've 'guarded' my famiily with everything.....double action 44's, 41's, 45's; single action too; SKS, Shotgun, 1911 45 acp and 10mm.. and probably a couple more, like the little snubby in my truck.
Hey, I had a thought; looking at what I just said, why not pick a arm that you will be more likely to use and practise with (other than in the home) ?? If you backpack, maybe a sidearm. Or maybe a rifle in the truck for the long trips...you should be familiar with this weapon, you should know what it does and enjoy using it well. Lot's of my firearms get double duty at all sorts of things...