The design and construction of stable porous networks featuring tunable cavities for selective guest inclusion remains a great challenge in construction of functional miniature devices. Herein we report on construction and guest inclusion of stable 2D porphyrin-based molecular square grids connected by imine bonds showing crystalline pattern with periodic square cavities. Diperylene diimides molecules can be decorated into the square pores of the porphyrin-based molecular template on HOPG surfaces. The periodicity control over the covalent molecular grid and thus that of guest molecules is demonstrated by changing the building block. The preparation of robust host–guest systems may facilitate the fabrication of molecular miniature devices with designable properties.