Highlights •Mg2+ is doped into the HVO to tune its structure through inserting into the lattice spacing of tunnel framework or substituting V4+ in the octahedron.•The insertion of free Mg2+ effectively widens the layer spacing and the formation of Mg-O bond stabilizes the cathode structure. However, excess Mg-O bonds will hinder zinc transport and reduce capacity.•When the doping amount of Mg2+ is 2 mmol, MgHVO gets appropriate layer spacing and stable structure, resulting in the excellent electrochemical performance.