Why do my shallots keep turning blue? Title sums it up, every now and then I'll notice that shallots sometimes take on a pronounced blue (or purple) tinge after cooking. I've noticed it when they're sauteed or roasted, seemingly independent of other ingredients. I'm aware of a similar, more common phenomenon with garlic, but that involves some source of acidity and copper, which hasn't always been present (eg. just shallots and olive oil in a nonstick pan). As such, I'm assuming there's another cause at work.
Vegetables with a naturally blueish-red color - red cabbage, beets, red onions, shallots, blueberries, red grapes (wine too) - usually have that color due to anthocyanin content.

Anthocyanin behaves like litmus paper, and takes on a different hue depending on pH value. If food containing it turns blue, it is too alkaline - and might also be at less than optimal flavor because of that. Add acidity to make it red.

Specifically with shallots, though, do make sure that it is not actually blueish mold getting washed into the cooking liquid. Unpalatable at any pH.