In this paper, a new scheme, which has energy-preserving property, is proposed for solving the sine-Gordon equation with periodic boundary conditions. It is obtained by the Fourier pseudo-spectral method and the fourth order average vector field method. In numerical experiments, the new high order energy-preserving scheme is compared with a number of existing numerical schemes for the one dimensional sine-Gordon equation. The new high order energy-preserving scheme for the two dimensional sine-Gordon equation is also investigated. Numerical results are addressed to further illustrate the conservation of energy and the evolutional behaviors of solitons.