Targeted modification of electronic structure is an important step in the optimization of metal-organic frameworks (MOFs) for photovoltaic, sensing, and photocatalytic applications. The key parameters to be controlled include the band gap, the absolute energy position of band edges, the excited state charge separation, and degree of hybridization between metal and ligand sites. Partial metal replacement, or metal doping, within secondary building units is a promising, yet relatively unexplored route to modulate these properties in MOFs. Therefore, in the present study, a general method for selecting metal dopant is worked out in theory and validated by experiment, retaining MIL-125 and UiO-66 as the model systems. Metal mixing enables targeted optimization of key electronic structure parameters. This method is applicable to any MOF architecture and can serve as a roadmap for future synthesis of MOFs with predefined properties.