Our work presents insights from density functional theory calculations on the trapping mechanism of light metal atoms in C2N-h2D. The storage capacity of C2N-h2D for lithium, sodium and calcium ions has been explored for utilisation as a battery anode material. Our calculations show that a significant capacity of over 500 mAh g−1 and excellent mobility of the calcium atoms can be achieved. Overall, we find that all three metals interact strongly with the pyridinic nitrogen in the pores and that the material shows a high initial storage capacity. However, due to the strong binding of the first intercalated metals in the pores, these show poor mobility. Once the pores are loaded with at least one metal atom, the mobility improves significantly. The trapped metal atoms however, affect the capacity of the material, making it much smaller. This limits the suitability of C2N-h2D as an anode material for lithium and sodium ion batteries and explains previous experimental findings on poor performance for lithium. For calcium we find that the trapping of some of the calcium atoms has less of an effect due to the dual valence, leading to the observed higher capacity.