Consuming garlic and onions is not recommended in both Yoga and Ayurveda.
Even though they have significant medicinal and scientific properties, energetically, onions and garlic are prohibited in many cultures.
Interestingly, there is a legend associated with the origin of garlic and onions. It is believed that while Lord Vishnu was busy serving the nectar of immortality to Rahu and Ketu, they informed Lord Vishnu of their actual demonic existence. Since Lord Vishnu had already served them the nectar, he immediately beheaded them and a few drops of their blood fell to the ground. As per the legends, onions and garlic sprouted from this odd combination of demonic blood and the nectar of immortality. Therefore, from the perspective of Yoga and Ayurveda, these vegetables offer potentially high medicinal properties (the nectar analogy) while also exerting destabilizing effects on the mind activity (the demonic analogy).
In Ayurveda, diet begins more with the energetic properties and taste of the foods and their impact on our body and mind, than their nutritional properties. In Yoga, the purpose of practice is to keep the state of mind uplifted and calm, and to keep the body light and energetic. To keep mind in a conducive state for meditation, and the body energetic and balanced, both Ayurveda and Yoga recommend a Sattvic (calming) diet that eliminates these two foods due to their highly stimulating properties.
Yoga and Ayurveda consider food as energy and each food has a specific impact on our energetic traits. When we consume foods that help give rise to negative qualities in the mind such as stimulation, aggression, anger, irritability or over excitement, irrespective of their positive nutritional profile, we directly tax the nervous system with these stimulating traits of the mind, therefore weakening our system further.
Onions and garlic are considered to be Rajasic (stimulating) foods that cause over stimulation, generate excess heat and energy in the body. These heating qualities may trigger anger, aggression and irritability.
The taste of onions and garlic is pungent. Ayurveda explains the properties of pungent foods as heating and increasing bile in the body. Therefore, many yoga practitioners stay away from these two foods.