A high-sugar diet can trigger or contribute to depression in a number of ways, including by:
Distorting your microflora by nourishing microbes that are detrimental to health
Triggering a cascade of chemical reactions in your body known to promote chronic inflammation
Elevating your insulin level, which can have a detrimental impact on your mood and mental health by causing higher levels of glutamate to be secreted in your brain. Glutamate has been linked to agitation, depression, anger, anxiety and panic attacks
Suppressing activity of brain-derived neurotrophic factor (BDNF), a growth hormone that promotes healthy neurons. BDNF levels are critically low in both depression and schizophrenia, which animal models suggest might actually be causative
I too believe the dietary answer for treating depression starts with limiting or eliminating refined sugars (especially processed fructose) and grains, as all forms of sugar feed bad bacteria in your gut and promote systemic-wide inflammation. As a standard recommendation, I suggest limiting your daily fructose consumption from all sources to 25 grams per day or less.
Cutting out processed foods will also significantly reduce your exposure to genetically engineered ingredients, which have also been implicated in chronic inflammation and the destruction of healthy gut bacteria, as well as pesticides such as glyphosate — another culprit in both microbiome disruption and inflammation. Keep in mind that conventionally grown foods may also be contaminated with pesticide residues so, ideally, aim for as organic a diet as you can.