The measurements of the inclusive and differential fiducial cross sections of the Higgs boson decaying to a pair of photons are presented. The analysis is performed using proton-proton collisions collected with the CMS detector at the LHC at a centre-of-mass energy of 13 TeV and corresponding to an integrated luminosity of 138\,\text{fb}^{-1}. The inclusive fiducial cross section is measured to be \sigma_{\text{fid}}=73.40_{-5.3}^{+5.4}\text{(stat)}_{-2.2}^{+2.4}\text{(syst)}\,\text{fb}, in agreement with the standard model expectation of 75.44\pm4.1\,\text{fb}. The measurements are also performed in fiducial regions targeting different production modes and as a function of several observables describing the diphoton system, the number of additional jets present in the events, and event-level observables. No significant deviations from the standard model expectations are observed.