The chemical evolution of protoplanetary discs is a complex process that is not fully understood. Several factors influence the final spatial distribution of atoms and molecules in the disc. One such factor is the inward drift and evaporation of volatile-rich pebbles that can enrich the inner disc with vapour. In particular, the inner disc is first enriched with evaporating water-ice, resulting in a low C/O ratio, before carbon-rich gas from the outer disc – originating from the evaporation of CO, CO2, and CH4 ice – is transported viscously inwards, elevating the C/O ratio again. However, it is unclear how internal photoevaporation – which carries away gas and opens gaps in the disc that can block inward drifting pebbles – affects the chemical composition of the disc. Our goal is to study how and to what extent internal photoevaporation and the subsequent opening of gaps influence the chemical evolution of protoplanetary discs around solar-like stars (M* = 1 M⊙), where we specifically focus on the C/O ratio and the water content. To carry out our simulations, we use a semi-analytical 1D disc model. The code chemcomp includes viscous evolution and heating, pebble growth and drift, pebble evaporation and condensation, as well as a simple chemical partitioning model for the disc. We show that internal photoevaporation plays a major role in the evolution of protoplanetary discs and their chemical composition: As photoevaporation opens a gap, inward drifting pebbles are stopped and can no longer contribute to the volatile content in the gas. In addition, volatile-rich gas from the outer disc, originating from evaporated CO, CO2, or CH4 ice, is carried away by the photoevaporative winds. Consequently, the C/O ratio in the inner disc remains low. In contrast, gaps opened by giant planets still allow the gas to pass, resulting in an elevated C/O ratio in the inner disc, similar to the evolution of viscous discs without internal photoevaporation. This opens the possibility to distinguish observationally between these two scenarios when measuring the C/O ratio, implying that we can infer the root cause of deep gap structures when observing protoplanetary discs. In the case of a clear separation of the disc by photoevaporation, we additionally find an elevated water content in the inner disc, because the water vapour and ice undergo a cycle of evaporation and recondensation, preventing the inward accretion of water onto the star, in contrast to the situation for hydrogen and helium. We conclude that it is very difficult to achieve supersolar C/O ratios in the inner parts of protoplanetary discs when taking internal photoevaporation into account. This indicates the potential importance of photoevaporation for understanding the chemical evolution of these discs and the planets forming in them.