When I moved out here two years ago, I figured 80% of the startups out here were in Mountain View, Palo Alto, and Cupertino. I was pleasantly surprised how many startup are in the city ("the city" is what locals call San Francisco).
You can't go wrong either or... it depends on your needs and there is no right answer. Both are good options.
A few tips: Try to be within reasonable walking distance of either a BART station or the Caltrain. This will give you an excellent public transportation option to easily bypass freeway gridlock when travelling between the Peninsula and SF.
Also, a good option may be a happy middle... such as San Mateo or Burlingame. There are startups here as well and you wouldn't be more than 30 mins on the train to Mountain View or SOMA, San Francisco.
EDIT to add disclaimer: I live in MV within walking distance of YC actually. It's very nice but also an hour to SF on the train.