For Great Person cities, get the most food possible, so you can sustain as many specialists as possible.
For all other cities, the only point of food is to allow you to use all your squares, so 2 for each square. In general, that is 20 squares, but there can be overlap with other cities, or useless squares like mountain or desert.
Count up your deficit from this goal (the difference of each usable square from 2). For example, each flood plain is +1, each plain is -1, each Fish is +4. The amount of farms is the number needed to overcome this deficit. If you have a total deficit of 5, you would need to use, say, 2 farms and 1 windmill.
If its a commerce city, put cottages on the rest of the squares. If it's a production city, it's a bit harder, since you can't just mindlessly put the same improvement on every square, but it's the same idea - mine all the rest of the hills and lumbermill the forests, watermill next to rivers and maybe use some workshops(keeping in mind that each one you use adds 1 to your deficit, so you need to recalculate, unless in State Property).
In general, the majority of your cities will probably be commerce cities, with no more than 1 GP farm, and a couple production cities: a military city with National Epic and West Point and a wonder city with Ironworks and maybe Red Cross. Towns are pretty overpowered in terms of the return they give you and commerce cities are certainly more versatile, since they can be used for science, to buy production and to upgrade units.