A method for producing polymeric carbon nitride formed by units of the formula C 6 N 7 (NH 2), wherein said process takes place in the solid phase and comprises: a) obtaining a solid mixture comprising a carbon nitride precursor and at least one acid-base catalyst, and b) treating the mixture obtained in step a) between 400°C and 800°C in an inert gas atmosphere, wherein the method is characterised in that: - step b) is carried out in a system having a configuration that, i) if the internal pressure of the system is between a threshold input pressure (p ei) and a threshold output pressure (p si), does not allow the inflow and outflow of gases; ii) if the internal pressure of the system is lower than the threshold input pressure (p ei), allows the inflow of an inert gas at an external pressure (p ext); and iii) if the internal pressure of the system is greater than the threshold output pressure (p si), allows the outflow of gases; wherein the threshold input pressure ( p ei) is between 1.0 and 1.5 atm, the external pressure ( p ext) is between 1.2 and 1.7 atm, and the threshold output pressure ( p si) is between 1.5 and 3 atm. a) obtaining a solid mixture comprising a carbon nitride precursor and at least one acid-base catalyst, and b) treating the mixture obtained in step a) between 400°C and 800°C in an inert gas atmosphere, wherein the method is characterised in that: - step b) is carried out in a system having a configuration that, i) if the internal pressure of the system is between a threshold input pressure (p ei) and a threshold output pressure (p si), does not allow the inflow and outflow of gases; ii) if the internal pressure of the system is lower than the threshold input pressure (p ei), allows the inflow of an inert gas at an external pressure (p ext); and iii) if the internal pressure of the system is greater than the threshold output pressure (p si), allows the outflow of gases; wherein the threshold input pressure ( p ei) is between 1.0 and 1.5 atm, the external pressure ( p ext) is between 1.2 and 1.7 atm, and the threshold output pressure ( p si) is between 1.5 and 3 atm. - step b) is carried out in a system having a configuration that, i) if the internal pressure of the system is between a threshold input pressure (p ei) and a threshold output pressure (p si), does not allow the inflow and outflow of gases; ii) if the internal pressure of the system is lower than the threshold input pressure (p ei), allows the inflow of an inert gas at an external pressure (p ext); and iii) if the internal pressure of the system is greater than the threshold output pressure (p si), allows the outflow of gases; wherein the threshold input pressure ( p ei) is between 1.0 and 1.5 atm, the external pressure ( p ext) is between 1.2 and 1.7 atm, and the threshold output pressure ( p si) is between 1.5 and 3 atm. i) if the internal pressure of the system is between a threshold input pressure (p ei) and a threshold output pressure (p si), does not allow the inflow and outflow of gases; ii) if the internal pressure of the system is lower than the threshold input pressure (p ei), allows the inflow of an inert gas at an external pressure (p ext); and iii) if the internal pressure of the system is greater than the threshold output pressure (p si), allows the outflow of gases;