Optical logic gates are a basic and fundamental component for optical networks and optical computing. The authors propose a structure for AND, NAND, XNOR, and NOR logic gates in two-dimensional photonic crystal, which utilizes dispersion-based self-collimation effect. The self-collimated beam is split by the line defect and interferes with other self-collimated beams. This interference may be constructive or destructive based on its phase difference. This phenomenon is employed to realize all optical logic gates. The gates are demonstrated numerically by computing electromagnetic field distribution using finite difference time domain (FDTD) method. The results ensure that this design could function as AND, NAND, XNOR, and NOR logic gates. The size of the structure is about 10 µm × 10 µm, which, in turn, results in increasing the speed, and all the gates are realized in the same configuration. On-off contrast ratios of the gates are about 6 dB.