Different forms of minerals are absorbed better or worse than others. It’s not exclusively a “food-based” versus “supplement-based” dichotomy.
Many minerals in grains and legumes are bound to phytic acid, meaning that you can’t absorb them very well (especially if uncooked or unfermented). Iron found in plants is much less bioavailable than iron in animals (like red meat) and the Institute of Medicine recommends double (1.8x) the intake of iron if you are getting it from plant-based sources instead of meat.
Like @horsfield said, magnesium gluconate or citrate is absorbed more readily than, say, magnesium oxide. And even magnesium oxide may perhaps be absorbed better than a magnesium phytate complex found in a grain or legume or nut. The magnesium in leafy greens or dairy products, however, might be absorbed very well. I’m not sure of the exact numbers on those.