We present here a method that can calculate NMR shielding tensors from first principles for systems with translational invariance. Our approach is based on Kohn-Sham density functional theory and gauge-including atomic orbitals. Our scheme determines the shielding tensor as the second derivative of the total electronic energy with respect to an external magnetic field and a nuclear magnetic moment. The induced current density due to a periodic perturbation from nuclear magnetic moments is obtained through numerical differentiation, whereas the influence of the responding perturbation in terms of the external magnetic field is evaluated analytically. The method is implemented into the periodic program BAND. It employs a Bloch basis set made up of Slater-type or numeric atomic orbitals and represents the Kohn-Sham potential fully without the use of effective core potentials. Results from calculations of NMR shielding constants based on the present approach are presented for isolated molecules as well as systems with one-, two- and three-dimensional periodicity. The reported values are compared to experiment and results from calculations on cluster models.