ABBA's Bjorn Ulvaeus and Benny Andersson conceived "Dancing Queen" as a dance song with the working title "Boogaloo," drawing inspiration from the 1974 George McCrae disco hit "Rock Your Baby." Their manager Stig Anderson came up with the title "Dancing Queen."
The lyrics for "Mary, Did You Know?" were written by Christian singer and comedian Mark Lowry, after his pastor asked him to write a Christmas musical for their church. Southern gospel musician Buddy Greene later added music to his words.