Octahedral CdS–ZnS composites were synthesized using a simple method of cation exchange and hydrothermal treatment, using Cd3(C3N3S3)2 (denoted as Cd3(TMT)2) as a precursor and Zn2+ for ion exchange. In the spontaneous ion exchange process, there is the formation of compact heterojunctions and three-dimensional octahedral structures. By controlling the ion exchange level, the composition of (CdxZn1–x)3(TMT)2 hybrid nanomaterials can be regulated, and the composite can be used as a template to generate octahedral CdS–ZnS. Photocatalytic oxidation of toluene to benzaldehyde was used as a model reaction to evaluate the performance of the as-prepared samples, and the CZ-2 catalyst shows the highest photocatalytic activity, giving a benzaldehyde formation rate of 1078 μmol·g–1·h–1 without the need of any solvent. The excellent performance is ascribed to the octahedral structure which is large in specific surface area and compact in heterojunctions. It is envisaged that the method is suitable for the generation of heterojunctions for photocatalytic purposes.