Mix the 1 cup granulated sugar, 1 teaspoon xanthan gum, and a pinch of salt in a small bowl.
Pour the 2 cups whole milk and the sugar mixture into a saucepan and bring to a simmer over medium heat.
Stir continuously until the sugar dissolves completely, 2 to 3 minutes. Don’t let the mixture boil.
Slide the saucepan off the heat and whisk in the 1 cup heavy cream.
Add the ¾ cup pistachio paste and 1 teaspoon vanilla extract.
Whisk until smooth. (I use an immersion blender for this, but you can also use a canister blender.)
Cover the bowl and slide it into the fridge to chill for at least 4 hours or, for better flavor and texture, overnight (8 to 12 hours).
Pour the chilled pistachio gelato base into an ice cream maker and churn according to the manufacturer’s instructions until it reaches a soft-serve consistency.
Add the ½ to ¾ cup coarsely chopped pistachios if using.
Transfer the ice cream to an airtight container and freeze until firm.
Remove the gelato from the freezer 10 minutes before serving.
