The octet rule is a fundamental theory in the chemical bonding of main-group elements, which achieve stable configurations by gaining, losing, or sharing electrons. However, the conventional octet rule, as depicted through Lewis structures, is inadequate for describing the electron delocalization in boron allotropes and boron-rich compounds due to the electron deficiency of boron. To address this, we introduce the concept of fractional electron occupancies, which more accurately reflect the electron delocalization in boron systems. Based on this, we propose a generalized octet rule that provides a more comprehensive understanding of the complex bonding configurations in boron allotropes and boron-rich compounds. Importantly, our predictions for α-B12 are validated by both first-principles calculations and existing experimental data. Beyond boron, this generalized octet rule is also applicable to systems with multiple resonance structures.