Pathfinding is very predictable so it's fairly easy to make invaders commit suicide.
The 'goblin grinder' under the 'trap design' entry in the wiki is easy, safe and powerful enough against regular sieges. Trapped corridor, pressure plate linked to a hatch at both ends. One small refinement: put the hatches a little further away from the pressure plates to the goblins will grind themselves rather than falling into the pits.
It's a very pedestrian trap though - useless against flyers, building destroyers and trap avoiders.
You can get trap avoiders by replacing triggers with repeaters (this also means upright spike traps instead of weapon traps).
You can get fliers by replacing pits with upward ramps covered by a hatch.
If you want something more powerful, your imagination is the limit. A good start is a repeater-driven containment system and many things to do with the holding area.
Spikes on every tile hooked up to a repater that you can turn on and off.
The ability to fill it with water or magma at will and drain it again.
Maybe some more exotic death traps (ice, smoke)
A shooting gallery of fortifications.
A corridor to your fortress lined with cage traps... allows you to retrieve loot, send in dwarven gladiators or capture interesting things.
If you captured something interesting already, a cage or cell that allows you to release the beastie. Amusing with dragons or Giant Cave Spiders.
A high-quality room for your 'honoured guests'.
A cesspit with forgotten beast contaminants for fates worse than death.
100000 other things to make any evil overlord cackle with glee.
Of course, you don't have to go for efficiency and controllability of a dedicated dungeon. Screaming goblins in decorative waterfalls or falling 20 z-levels down directly into one's main hall really set the tone. The more fun and elaborate things tend to take time though, a slightly optimised goblin grinder will buy you all the time you need.