"Where Did You Get That Hat?" is a song composed by J.J. Sullivan.
Margaret Bradford Boni in Songs of the Gilded Age (1960) writes:
Sullivan, comedian and acrobatic dancer, home for vacation and searching in the attic for possible make-up material, came across an old plug hat, too small for his head and absurdly tall for his short, plump figure. Wearing it, he ventured into the street and was ridiculed and jeered at by a group of small boys, who yelled: "Where did you get that hat?" The phrase gave him the title for his celebrated song, one of the best-remembered hits of 1888, which for years after was sung and played everywhere.
The melody is based partly on a leitmotiv from Wagner's Lohengrin.
The song was sung by Gene Kelly in the 1949 film Take Me Out to the Ball Game.
It was also recorded by the English comedian Stanley Holloway.
I learned it (with a slightly altered melody) from Bob Carlin at Midwest Banjo Camp.
broadsheet