Are you allowed to have religious or personal beliefs as a politician?

Can you be a politician with religious or personal beliefs? The former leader of the Liberal Democrats Tim Farron resigned due to conflicts with leading a...