The main difference in defending a town rather than a single fortified private residence is the area that needs to be defended: the town core is naturally much larger than the size of a single keep or bailey and so the circuit of walls surrounding it also needs to be much longer. That longer circuit, of course, means a higher cost in terms of constructing and maintaining the defense, but the advantage a town often has here is its own residents: the populace of a town often has a fair bit more labor to devote to defense construction compared to the medieval aristocracy who mostly draw their power and resources from the more thinly populated rural countryside.
Nevertheless, the larger size of the area being defended makes it harder to deploy concentric defense-in-depth solutions. There are also transit considerations: towns are, after all, economic centers, typically sitting at the junction points of many different local and regional routes, which means they tend to need lots of entry-points to facilitate all of that travel and trade and in turn that means lots of potentially vulnerable gatehouses. Meanwhile, internally, the desire for residents to move around the town freely and general land-use considerations make subdividing towns into walled districts (very common in video-games for memory-management and loading reasons) very difficult and as a result very rare. You can see this, for instance, looking back at the period city-maps from the Lonely Cities series: a good number of cities have either a citadel or a section of the town which is walled but also outside of the main circuit (often separated by a river), but full concentric styles of defense or multiple cell-like walled districts don’t really occur. There are exceptions, but they are relatively rare: most cities have a single primary circuit of walls, which, if they are breached generally give access to the main area of the town.
In Europe, the most complete and formidable set of city walls were without question the Theodosian Walls built to defend Constantinople during the reign of Theodosius II (r. 402-450). The Theodosian Walls stood for the whole Middle Ages but they really reflect the culmination of the ancient system of city wall fortifications, the ultimate answer to the kind of “big army” playbook the Assyrians (and Romans) employed. So I want to both talk about the defense system but also note points where its method diverges from the walls of later medieval towns.
The Theodosian Walls had to cover some 5.7km and had nine gates; both numbers should immediately make clear that you needed quite a few people to man these defenses effectively. This was in particular a factor for town defense: most of the defenders are going to be citizens of the town called up to defend it in an emergency, rather than a standing guard. As far as I can tell, this seems to have made towns somewhat more vulnerable to surprise “hasty assaults”, if the attacker could force a gate along a long circuit before the defenders knew where the attack was coming. Of course that problem is intensified by the fact that this is a single-point-of-failure system: the loss of one gate against a superior foe generally meant the loss of the town.
The Theodosian Walls are unusual in that they are a set of triple walls. The main fighting position was on the inner wall; in front of this was the peribolos, a low, flat, unobstructed gap, after which was the lower outer wall, a secondary forward fighting platform. The towers of the inner wall project out into the peribolos for exactly the same reason castle towers project: defenders on those towers can fire, unobstructed, down the peribolos, meaning that an attacker can find no safety here. The crenellation of the outer wall likewise only faced out, so attackers who seized the outer wall would have no cover from defenders fighting from the inner wall. Next, after another gap was a simple low forward wall, little more than a stone breastwork about 1.5m high. Finally, the low wall stood at the inner edge of a large moat, some 20m wide and 10m deep, because no good defensive system is complete without a ditch.
That low wall is a kind of what we call an “outwork”. This particular kind of outwork is a product of the ancient world and uncommon in medieval fortifications to my knowledge; it was a response to the increasing use of torsion catapults during the Hellenistic period. While it did offer a position for defenders to use to sally out (for instance to destroy enemy siege engines), the primary purpose was to prevent enemy catapults from being able to direct fire at the base of the main wall and its towers. Even if knocked down, such an outwork’s rubble would obstruct direct fire on the curtain wall or the towers. This idea – using an outwork to physically block lines of fire on the curtain wall – is going to come back a bit later.
In contrast, most later medieval town wall circuits generally only have a single curtain wall, supported by a moat. As with castles, the wall is supported by projecting towers which can direct fire along its length and hardened gatehouses. Where cities sometimes do employ defense-in-depth it is with a “citadel” – a hardened fallback position either inside the city or (more often) built in to the wall circuit; essentially a complete castle built into the city wall. The role of the citadel is important for thinking about what these defenses are intended to achieve: defenders who have lost the main area of the city but have held out in the citadel are unlikely to be in a position to recapture the city or even to seriously threaten to do so. But the citadel has important negotiating power. Even a small number of surviving defenders can likely hold a citadel (with its stockpile of supplies) for a long time; taking such a citadel by storm poses all of the problems of storming a castle, with the added disadvantage of having to do so through city streets. Consequently, defenders holed up in the citadel are in a good position to negotiate for terms: perhaps being able to march out unharmed in exchange for turning over the citadel, or else negotiate less onerous terms for the city in general (alternately, they might try to hold out until a friendly relief army could arrive).
And that brings the focus to something important about almost all medieval siegecraft: the siege and negotiations generally proceeded side-by-side. By raising the cost of a siege (either a blockade or a storming assault), the defender could improve their bargaining position, even if they were always going to have to surrender. Meanwhile the attacker, by very visibly preparing for a deliberate assault could signal to the defenders their resolve and thus attempt to encourage surrender. As far as I can tell, far more fortified medieval towns and castles surrendered than were ever taken by storm and so consequently a lot of this fortification work is as much about shifting bargaining positions in the event of an attack as it is resisting an attack.
Bret Devereaux, “Collections: Fortification, Part III: Castling”, A Collection of Unmitigated Pedantry, 2021-12-10.