Specialisation is massive. Whenever I see my empire sort of flatlining towards the middle ages, it's generally because I've been lazy with my specialisation.
The most important thing (in my experience) is a specialised Heroic Epic city. If you specialise nothing else, at least have this. Use your very best gamelong production site - High food, good production and, if possible, riverside (lategame levees), with nothing but farms, mines and workshops. Build nothing but granary, forge, barracks, stables, and maybe a happiness building or two when needed (supplemented by powered factories and corresponding health buildings later on, of course). Give it Heroic Epic and West Point when you can. Apart from the above buildings, build NOTHING but military units from this city EVER. Stick a bunch of great generals as military instructors here too. You can produce most of your army from a single city this way, and it will be a well-trained army too.
The rest are less important and can come later. A good GP farm, a couple of good cottagespam cities, a decent coastal military production city for navy and surplus army needs, a Wall Street money city running merchants (quite often the GP farm city too), an espionage city running spy specialists, etc.
A HUGE help for me is to look at my empire after any mad expansion rush, use alt-s, and label every city with a primary specialisation. Really forces your hand into choosing what that city is going to do, and then constantly reminds you throughout the game so that you stick with it. Well worth it.