Prepare moulds by greasing them lightly with coconut milk or butter. If you’re not using moulds, then just have a serving dish ready.
In a large, heavy-bottomed pan and on low-medium heat, melt the butter and let this sizzle for some minutes as though you’re making ghee.
Once this is fragrant and maybe a little nutty like brown butter, add the ube. Mix well.
Follow soon after with the coconut milk. Add this in batches, mixing well to incorporate each time.
Keep stirring as this thickens very fast.
Once the ube softens, you have two choices. You can transfer the whole mixture to a blender and whizz until very smooth, or you can keep cooking as-is and leave the halaya a bit more textured. Most modern halaya will be smooth-textured, so that’s the process I’ve followed.
Now pour the puree back into the cooking pan, back on low-medium heat.
Add in the sugar and the condensed milk, if using.
Now roll up your sleeves and continue mixing as the mixture thickens. Do not leave the halaya unattended. Ube is a heavy yam, so the mixture will catch and burn easily and it takes strength to keep it moving. Use a metal spatula that allows you to scrape down the bottom and sides of the pan easily.
Cook this mixture down until you start to see the fats from the coconut milk and butter release from the sides.
Add the ube flavor and coloring, if using.
Turn off the heat and transfer to moulds.
Toast the nuts and raisins in a little oil or butter, if using to garnish.
This halaya is best served warm. It keeps well, refrigerated, for several weeks. Reheat gently to serve.