Shale pore evolution and variation are very important for evaluating shale reservoirs. In this study, hydrous pyrolysis experiments in a semiclosed system, low-pressure gas (N2 and CO2) adsorption, X-ray diffraction, organic petrography, and geochemistry experiments were applied on upper Permian organic-rich shale from Dalong Formation, Sichuan Basin, to understand the generation and evolution of nanometer-sized pores in shales. According to the pore structure parameters, most of the specific surface area (SSA) is supplied by micropores (<2 nm), whereas macropores (>50 nm) supply the bulk of the total pore volume (PV). The total PV and SSA are positively connected with thermal maturity (%Ro) and they share two peaks with corresponding % Ro values between 0.79-1.05% (peak I) and 1.83-2.35% (peak II), representing the two major periods of pore development. Peak I is associated with the late period of oil generation and the late period of kerogen cracking to gas, and peak II is associated with the cracking peak of the extractable organic matter (OM) to gas. The evolution of porosity was slightly affected by the mineral composition and total organic carbon (TOC) due to the main influence of thermal maturity, which masked the influence of mineral composition and TOC. Shale porosity formation and development are primarily influenced by diagenesis and hydrocarbon generation. Cementation can significantly reduce the overall porosity during diagenesis. It has been shown that OM pores are a function of thermal maturity, which is highly associated with the thermal cracking of both kerogen and secondary OM into hydrocarbon. During the overmaturity stage with %Ro > 2.67%, the porosity shows an increased trend due to the high gas generation rate. This illustrates that during the high maturity stage, OM pores are better formed, which is crucial for expanding shale gas exploration to more mature shale resources.