We introduce an effective field theory for the nonlinear optics of photonic crystals of arbitrary dimensionality. Based on a canonical Hamiltonian formulation of Maxwell's equations, canonical effective fields are introduced to describe the electromagnetic field. Conserved quantities are easily constructed and their physical significance identified; the formalism can be easily quantized. We illustrate the approach by considering a periodic Kerr medium, and show how the nonlinear coupled mode and nonlinear Schrödinger equations emerge. We extend the latter to treat optical shock effects, and compare our canonical formulation with earlier treatments.