Recently, hydrogen-based distributed generators (DG) have gained significant attention for modern energy generation systems. These modem DGs are typically outfitted with power electronics converters, resulting in harmonic pollution. Furthermore, increasing the growth of modern nonlinear loads may result in exceeding the harmonic beyond the permitted level. This research proposes a framework for optimal incorporation of inverter-based distributed generation (a fuel cell connected to an AC distribution system) for minimizing power losses, enhancing the voltage profile, and limiting both total and individual harmonic distortion according to the IEEE-519 standard. In addition, for accounting system sustainability, the proposed framework considers load variation and the expected rise in demand. Therefore, the suggested framework comprises three stages, which include fundamental and harmonic power flow analysis. The first stage identifies the optimal size and location of the DG in relation to the base load operating condition. While, with the optimal DG of the first stage, the amount of harmonic pollution may violate the limits during a high level of nonlinear load penetration, as a result, the second stage resizes the DG, considering the connection bus of the first stage, to mitigate the harmonics and optimize the system at a higher level of nonlinear load penetration. Both the first and second stages are performed off-line, while the third stage optimizes the system operation during run time according to loading conditions, harmonic pollution, and the available DG capacity of the previous stages. DG’s harmonic spectrum is represented according to recently issued IEEE 1547-2018 for permissible DG’s current distortion limits. The suggested approach is applied and evaluated using an IEEE 33-bus distribution system for various combinations of linear and nonlinear loads. For run-time operation throughout the day, the presented framework reduces the energy losses from 5.281 to 2.452 MWh/day (about 53.57% energy savings). This saving is associated with voltage profile enhancement without violating the permissible standard levels of harmonics and other system constraints.