Earthworks are a type of pre-deployment option in Empire: Total War.
When armies stay motionless on the world map for two turns and is attacked, certain units gain the ability to place useful objects on the field before a battle commences. Earthworks are one such option.
Though described as trenches, earthworks are depicted in the games as a downward sloping mound behind which infantry can shoot--essentially, a temporary wall. Earthworks greatly decrease the amount of damage incoming artillery, musket and rifle fire deal. A regiment using earthworks to their advantage can hold off superior forces for quite some time in a musket duel. However, earthworks do not protect from melee attacks or weapons with an arced trajectory, such as grenades or howitzer fire.
Generally, units that can deploy earthworks are militia and line infantry. Most units have the option between choosing Chevaux de Frise and earthworks. Like chevaux de frise, earthworks can be stretched out by stretching out the regiment deploying them. There is no disadvantage to doing this, and indeed it can be beneficial to do so to increase the defenses of an area. Compared to chevaux de frise, earthworks offer minimal, if any resistance to cavalry, but are far superior as defense against enemy fire.
Most light infantry and skirmishers do not have access to earthworks. No cavalry has access to earthworks (or any other pre-deployment options). Artillery do not have earthworks, but can deploy Gabionades, which provide similar benefits.