- In a medium saucepan, whisk together sugar, cocoa powder, cornstarch, and salt.
In a separate bowl, whisk egg yolks with milk until combined.
- Gradually whisk the milk mixture into the dry ingredients in the saucepan.
- Cook over medium heat, whisking constantly, until the mixture thickens and begins to bubble, about 8–10 minutes.
- Once thickened, remove from heat and stir in the butter and vanilla extract until smooth.
- Pour the hot chocolate filling into the pre-baked pie crust and smooth the top.
- Let the pie cool at room temperature for 30 minutes, then refrigerate for at least 4 hours or until fully set.
- Top with whipped cream and chocolate shavings before serving, if desired.