Inspired by the idea "let's write about our friends and the stupid stuff we did in New York,"How I Met Your Mother is Bays' and Thomas' idea. The two drew from their friendship in creating the characters, with Ted based loosely on Bays, and Marshall and Lily based loosely on Thomas and his wife. Thomas's wife Rebecca was initially reluctant to have a character based on her, but agreed if they could get Alyson Hannigan to play her. Fortunately, Hannigan was available, and was looking to do more comedy work.
The bar MacLaren's, in which some of the show is set, is based on a bar in New York City called McGee's. It has a mural that Carter Bays and Craig Thomas both liked and wanted to incorporate into the show. The name for the bar is from Carter Bays's assistant, Carl MacLaren; the bartender in the show is also called Carl.
Usually each episode is shot over three days (most sitcoms are typically shot in a single day) in the Los Angeles based Soundstage Studio 22 and features upwards of 50 scenes with quick transitions and flashbacks. The laugh track is later created by recording an audience being shown the final edited episode. Co-creator Thomas claims shooting in front of a live audience would be impossible, and doing so "would blur the line between 'audience' and 'hostage situation'". Later seasons started filming in front of an audience on occasion when smaller sets are used.
The theme song is a portion of "Hey Beautiful" by The Solids, of which Bays and Thomas, the two co-creators of the show, are members. Episodes from the first season generally started with the opening credits. A cold opening has been used since season two. Viewers then occasionally see Ted's children on a couch and hear him talking to them, telling the story of how he met their mother. Alternatively, scenes from previous shows or shots of New York City with Ted narrating over the top are shown....