Outside of “Star and Stripes Forever,” the song “Yankee Doodle” is most associated with the 4th of July holiday. We all learned it as kids, but never really understood it. My kids would sing the line “Stuck a feather in his cap and called it macaroni” and they would follow it with a shout of “and cheese!” because it makes no sense. But there really is an explanation.
The first bit of context you need in order to understand the sense of this line is that the song “Yankee Doodle” was not always the proud, patriotic ditty we know today. It was originally sung by British soldiers in mockery of the rough, unsophisticated, American colonials they had to fight alongside during the French and Indian War. The thrust of it was “look at these ridiculous yokels!”
The second bit of context has to do with what was going on back in England at the time.
It was a case of embracing an insult and making it our own. Read the rest of the story at mental_floss.