In this paper, we propose the mathematical and finite element analysis of a second-order partial differential equation endowed with a generalized Robin boundary condition which involves the Laplace--Beltrami operator by introducing a function space $H^1(\Omega; \Gamma)$ of $H^1(\Omega)$-functions with $H^1(\Gamma)$-traces, where $\Gamma \subseteq \partial \Omega$. Based on a variational method, we prove that the solution of the generalized Robin boundary value problem possesses a better regularity property on the boundary than in the case of the standard Robin problem. We numerically solve generalized Robin problems by means of the finite element method with the aim of validating the theoretical rates of convergence of the error in the norms associated to the space $H^1(\Omega; \Gamma)$.