Combine Dry Ingredients: In a heavy-bottomed pot or enameled Dutch oven, whisk together the sugar, unsweetened cocoa powder, and cornstarch until well combined.
Add Milk: Gradually whisk in the milk, ensuring a smooth mixture with no lumps.
Cook Mixture: Place the pot over medium heat, stirring continuously to prevent sticking. Cook until the mixture thickens and begins to bubble gently.
Temper Egg Yolks: In a separate medium bowl, lightly beat the egg yolks. Slowly add about 1 cup of the hot chocolate mixture to the egg yolks, whisking constantly to temper them.
Combine Mixtures: Pour the tempered egg yolk mixture back into the pot, stirring continuously.
Thicken Pudding: Return the pot to medium heat and cook for an additional 2 minutes, stirring constantly, until the pudding reaches your desired thickness.
Add Butter and Vanilla: Remove from heat and stir in the butter and vanilla extract until fully incorporated.
Cool Pudding: Pour the pudding into individual serving dishes or a large bowl. To prevent a skin from forming on the top of the pudding, place a piece of plastic wrap directly on the surface of the pudding.
Refrigerate: Allow the pudding to cool at room temperature for about 30 minutes, then refrigerate for at least 2 hours before serving.