Fuel cells can be used in sustainable cities for a variety of purposes, including emergency backup power systems, electric vehicle recharging, and the production of clean, efficient energy for buildings. Additionally, fuel cells can support distributed energy systems, improving energy management, and lowering dependency on conventional energy sources. However, the slow time response of proton exchange membrane fuel cell (PEMFC) during high-level load variation is an issue that needs addressing. To solve this, battery storage and supercapacitor can be integrated with a hybrid generation system including fuel cell, photovoltaic (PV). It's important to have effective energy management strategies (EMSs) to ensure the photovoltaic (PV) array, PEMFC, batteries, and supercapacitors function optimally. An EMS distributes the load demand among these components while maintaining high efficiency and low hydrogen consumption. This paper proposes an effective EMS for a hybrid generating system DC microgrid (MG) having PV, FC, battery, and SC based on recent Harris hawks optimizer (HHO) to manage the energy between the equipment while minimizing the total hydrogen consumption and enhancing the system efficiency. The research work compared several algorithms, including external energy maximization strategy (EEMS), equivalent consumption minimization strategy (ECMS), frequency decoupling and state machine control (FDSMC), proportional integral (PI), Cuckoo search (CS), and grey wolf optimizer (GWO), with the proposed HHO. The EEMS-based HHO algorithm outperformed the others resulting in 18.95 %, 38.77 %, 47.34 %, 34.43 %, 33.9 %, and 20.38 % hydrogen consumption reduction compared to PI, FDSMC, ECMS, EEMS, CS, and GWO, respectively. Moreover, efficiency improved by 7.62 %, 7.77 %, 17.15 %, 11.21 %, 2.17 %, and 5.12 % compared to PI, FDSMC, ECMS, EEMS, CS, and GWO, respectively. The obtained findings demonstrated the robustness and efficacy of the suggested HHO-EMS in obtaining the lowest hydrogen consumption of the DC microgrid that was provided.