Heat oven to 350°F. Butter the pan(s), line the bottoms with parchment, butter again, and dust with cocoa, tapping out the excess. (For cupcakes, there is no need for parchment or rebuttering.) In a medium bowl, whisk together the flour, cocoa, baking powder, baking soda, and salt; set aside.
Using an electric mixer, beat the butter and sugar on medium-high until fluffy, 2 to 3 minutes. Beat in the vanilla, then the eggs one at a time, scraping down the sides of the bowl as necessary.
Reduce mixer speed to low. Add the flour mixture in 3 additions and the milk in 2 additions, beginning and ending with the flour mixture. Mix just until combined (do not overmix).
Transfer the batter to the prepared pan(s) and bake until a toothpick inserted in the center comes out clean (see baking times, below). Cool the cake(s) in the pan(s) for 15 minutes, then turn out onto rack(s) to cool completely.
Baking times: For two 8-inch rounds: 30 to 35 minutes. For two 9-inch rounds: 25 to 30 minutes. For one 9-by-13-inch rectangle: 35 to 40 minutes. For 24 cupcakes: 20 to 25 minutes.