You might find this website covers the details on Vit D:
Your body was designed to generate its own Vit D through the skin, but in the UK you need strong sunlight direct on the skin between Apr-Oct around 1100-1500. Up north the time preiod is a bit more restricted, down south in midsummer a bit longer. But make sure you don’t get to the point where you get any redness – normally 10-15mins several times a week. There just is not enough UV of the necessary wavelength during the other months. Sunlight (specifically blue light) on the retina is makes melatonin, which is nothing to do with Vit D, it’s about sleep cycles and jet lag. Exposure through glass or plastic will not be effective for vitamin D, but will for melatonin.
A very few specific foods, mainly oliy fish, have significant amounts of vit D, but you do need to eat them consistenly. In the US some foods are fortified with vitamin D – so if you see comments on websites like “drinking milk gives you the vitamin D you need” that does not apply in the UK.