# Why is the Hamiltonian of a photon = 0?

I'm studying the motion of light near Schwarzschild black holes, and I was wondering why the Hamiltonian of the Schwarzschild metric $$H = - \left( 1-\frac{2M}{r} \right)^{-1} \frac{p_{t}^2}{2}+\left( 1-\frac{2M}{r} \right) \frac{p_{r}^2}{2}+\left( \frac{p_{ \theta}^2}{2r^2}+\frac{p_{\phi}^2}{2r^2\sin^2\theta} \right)$$ is equal to zero for photons. I know that $$H < 0$$ is for every other particle and $$H >0$$ is mathematically possible but physically very unlikely since it would mean the particle is travelling faster than light. Still I don't know why the Hamiltonian (sum of potential and kinetic energies) of photons equals 0. Could anyone please help me?

OP's Hamiltonian of the form $$H~=~\frac{p^2+m^2}{2}, \qquad p^2~:=~p_{\mu}g^{\mu\nu}(x) p_{\nu}~\leq~0,\tag{1}$$ is called a super-Hamiltonian in e.g. MTW, cf. e.g. this Phys.SE post. (For a massless particle like the photon $$m=0$$.) The super-Hamiltonian (1) is the $$e=1$$ gauge of the Hamiltonian $$H~=~ \frac{e}{2}(p^2+m^2)\tag{2}$$ for a relativistic point particle, cf. e.g. this & this Phys.SE posts. Here $$e$$ is a Lagrange multiplier field that imposes the mass-shell condition $$p^2+m^2~\approx~0.\tag{3}$$ For the super-Hamiltonian (1) the mass-shell condition (3) must be imposed by hand. The notion of energy is (as usual) tied to the notion of worldline (WL) parameter, cf. Noether's theorem. Because of WL reparametrization invariance, this energy notion is challenged, cf. e.g. this Phys.SE post.