Originally the poles were located at the end of the end zone, both in professional and collegiate games.
In 1933, the NFL relocated these posts to the goal line. A problem came up: passes and clearances from the end zone had to avoid hitting the posts, so the offense had the option to place the ovoide up to five yards off the hash mark without penalty, if the goal posts would interfere with their kick it or another move.
Thus, in 1967, an important modification emerged: the NFL left behind the "H"-shaped poles and regulated a new design (conspired by Joel Rottman), even that resembled a fork. The new goal posts were to be placed about a yard inside the end zone, with a pedestal that would extend a horizontal bar parallel to the goal line. This structure was supposed to be painted yellow.
In 1974, seeking more touchdowns and fewer field goals, the NFL moved the goal posts back to the end of the end zone, where they have remained to this day.