In vivo optical imaging of neural activity provides important insights into brain functions at the single-cell level. Cranial windows and virally delivered calcium indicators are commonly used for imaging cortical activity through two-photon microscopes in head-fixed animals. Recently, head-mounted one-photon microscopes have been developed for freely behaving animals. However, minimizing tissue damage from the virus injection procedure and maintaining window clarity for imaging can be technically challenging. We used a wide-diameter glass pipette at the cortical surface for infusing the viral calcium reporter AAV-GCaMP6 into the cortex. After infusion, the scalp skin over the implanted optical window was sutured to facilitate postoperative recovery. The sutured scalp was removed approximately two weeks later and a miniature microscope was attached above the window to image neuronal activity in freely moving mice. We found that cortical surface virus infusion efficiently labeled neurons in superficial layers, and scalp skin suturing helped to maintain the long-term clarity of optical windows. As a result, several hundred neurons could be recorded in freely moving animals. Compared to intracortical virus injection and open-scalp postoperative recovery, our methods minimized tissue damage and dura overgrowth underneath the optical window, and significantly increased the experimental success rate and the yield of identified neurons. Our improved cranial surgery technique allows for high-yield calcium imaging of cortical neurons with head-mounted microscopes in freely behaving animals. This technique may be beneficial for other optical applications such as two-photon microscopy, multi-site imaging, and optogenetic modulation.