In a stand mixer fixed with the paddle attachment, combine flour, brown sugar, baking soda, spices, and salt on low.
Next, stop the mixer, add the butter pieces and then mix at medium-low speed until the mixture is a sandy texture.
Mix cocoa powder, flour, salt, baking, powder, and espresso. Mix with butter mixture. Reduce mixer to low, gradually add the molasses and milk.
Mix until the dough evenly moist and mixed. Scrape down the sides of the bowl if necessary.
Take half the dough and, between two large sheets of parchment paper, roll it until it is 1/4 inch thick.
Repeat with other half of dough. Leaving the dough between the parchment paper.
Freeze the dough until firm or leave in the refrigerator overnight.
Preheat the oven to 350°F and line a baking sheet with parchment paper. Remove the dough from the parchment paper and cut out the gingerbread man.
Bake the cookies for 8 to 11 minutes. Allow the cookies to cool, then top with royal icing.
Repeat the process until all the gingerbread men are baked!