Controlling the battlefield is an important part of an effective military: with the right terrain and a little luck, green dwarves can hold off a horde of goblins, but under the wrong circumstances goblins can massacre your veteran soldiers. Make sure you meet the enemy at a place of your choosing.
I recommend arranging your walls and tunnels to force the enemy to meet your melee forces in a narrow corridor, where you can best negate their numerical advantage and prevent your dwarves from being surrounded. A path that twists before it reaches the point you've selected to fight will reduce the advantage of enemy archers because they won't be able to shoot at your troops without closing to melee range. It'll also reduce the problem of single dwarves running off after the first goblin they see and getting surrounded and cut down far from your defenses. Twists after the battle area help you to stage reserves out of sight of the enemy and get your medics back behind cover quickly when they come out after wounded. A guard animal out front will give you some advance warning of attacks.
Before committing melee troops to battle, I recommend assembling them out of sight of the enemy to give stragglers time to catch up. Alternately, you can use the military schedule and Defend Burrows order to have them go to a burrow you define. This is also a good workaround to no longer being able to tell dwarves not to chase fleeing enemies.
A balcony that overlooks the battle zone is a good place to put your marksdwarves where they can provide supporting fire without exposing themselves to danger. Even untrained recruits will help here. Position your marksdwarves so that they shoot down the long axis of the attackers, providing enfilading fire.
A tower for marksdwarves to use outside your defenses can also be effective. You'll need to keep your marksdwarves right up against the fortifications, so I recommend a one-tile-wide path between the fortifications and a wall backing them; alternately, you can use Defend Burrows orders to keep them up against the fortifications. As long as you're not facing enemy archers, an open platform atop the tower is also a great place to put them. You'll want to bring them down from the platform if marksgoblins show up and down from the tower if facing elite marksgobins, but otherwise they'll be safe and sound.
I've had issues with hunters, so I prefer to turn off hunting for all my marksdwarves and send them (with melee troops as backup) on paramilitary hunting expeditions using squad-level station commands. It's a good way to get them some basic training, and it means they have backup if things go wrong. I keep an eye on the unit list, and if there's anything tasty or annoying up top, out the marksdwarves come. I try to avoid fighting anything tougher than ordinary wildlife away from the safety of my fortifications, but if I must, I deploy ranged and melee troops in support of each other and try to use the terrain to my advantage.
I draft everyone who shows up with military skills, but those who also have valuable civilian skills end up assigned to reserve squads that I only employ if things are looking grim. I build a barracks near the entrance and set it so that all my squads (including marksdwarves, if I have no archery targets) can train there. I don't have to touch the alerts to have dwarves go there and practice when they don't have anything else to do, and it keeps their military skills from rusting away. The barracks is also a good staging point.
Anyone I don't know what to do with gets handed a crossbow. As long as you keep them out of melee and don't let them get pincushioned, marksdwarf quantity makes up for quality and makes things easier for your melee forces.
Once you've got the population to support a full-time militia, other folks' advice on training is quite good. I rotate melee troops into training if I get around to it, but I usually don't do more for marksdwarves than setting up a few archery ranges that they can use when off-duty. Quantity and effective deployment is usually good enough for me.