The Fourth of July is upon us, so it’s time once again to sing what is arguably our most baffling national ditty, “Yankee Doodle Dandy.” Maybe you’ve noticed: Some of the lyrics seem like the work of a prankster on acid. Who else could have conceived a vignette as bizarre as a man riding a pony into town, then sticking a feather in his cap that, for unknown reasons, he insists on calling “macaroni”?

The answer is not George M. Cohan, who wrote the ecstatically patriotic verses of “The Yankee Doodle Boy” for the 1904 musical “Little Johnny Jones.” He lifted the feather-and-cap lines from a song called, simply, “Yankee Doodle,” which was popularized by British troops during the Revolutionary War. And whoever composed these words — history is inconclusive — didn’t intend a jesting, surreal tribute to the colonists. Quite the opposite. The song is an insult.

It’s not just any insult, either. With “Yankee Doodle,” the Redcoats were delivering the most puerile, schoolyard insult in the schoolyard insult book. They were suggesting that American soldiers were gay.

Gay and bumbling, actually.

To decode this very un-P.C. put-down, you first need to know that the song has only a nominal connection to pasta. The macaronis were members of a subculture of British fops in the 1760s and 1770s, who took their name from the Italian ingredient that would have seemed exotic and sophisticated in England at the time. The trend started with aristocrats, but caught on with middle- and working-class lads as well.