The answer to this problem is both surprisingly simple to state, yet nearly impossible to achieve.
Educate the citizenry more effectively.
Were Hillary to have lost to Pence, Ryan, Cotton, whomever -- it would have likely been due to a difference in political ideology. However, this election was between an idiot and a serious politician (warts and all). Educated people simply couldn't look at Trump and think he was an appropriate choice.
On another note, the electoral college also failed us. They were established, according to my understanding, to be a check against a dangerous cult-of-personality type.