Preheat the oven: Prepare your oven to 175°C (350°F). Grease a 9x5-inch loaf pan with coconut oil or line it with parchment paper for easy removal.
Mix the dry ingredients: In a large bowl, whisk together the gluten-free flour, cocoa powder, baking powder, baking soda, salt, and xanthan gum (if needed). Ensure there are no lumps, particularly in the cocoa powder.
Combine the wet ingredients: In a separate bowl, whisk the coconut sugar and melted coconut oil until smooth. Add the eggs (or flax eggs) one at a time, mixing well. Stir in the almond milk and vanilla extract until fully combined.
Blend wet and dry mixtures: Add the dry ingredients to the wet mixture a little at a time, stirring just until combined. To keep the loaf soft, don't overmix. Add the dairy-free chocolate chips, if using, and fold.
Pour and bake: Transfer the batter to the prepared loaf pan, smoothing the top with a spatula. A toothpick inserted in the center should come out clean or have a few moist crumbs if you bake it for 40 to 45 minutes.
Cool and serve: After 10 minutes of cooling in the pan, move the loaf to a wire rack to finish cooling. Slice and serve hot or cold!