Eqs. (5) & (6) here show how leptons couple to the Higgs field, giving the former mass. They are terms in the Lagrangian, viz.
$$
\begin{aligned}
\mathcal{L}_{Y} =
&-\lambda_u^{ij}\frac{\phi^0-i\phi^3}{\sqrt{2}}\overline u_L^i u_R^j
+\lambda_u^{ij}\frac{\phi^1-i\phi^2}{\sqrt{2}}\overline d_L^i u_R^j\\
&-\lambda_d^{ij}\frac{\phi^0+i\phi^3}{\sqrt{2}}\overline d_L^i d_R^j
-\lambda_d^{ij}\frac{\phi^1+i\phi^2}{\sqrt{2}}\overline u_L^i d_R^j\\
&-\lambda_e^{ij}\frac{\phi^0+i\phi^3}{\sqrt{2}}\overline e_L^i e_R^j
-\lambda_e^{ij}\frac{\phi^1+i\phi^2}{\sqrt{2}}\overline \nu_L^i e_R^j
+ \textrm{h.c.}
\end{aligned}\tag5
$$
$$
\begin{aligned}
\mathcal{L}_{m} = -m_u^i\overline u_L^i u_R^i -m_d^i\overline d_L^i d_R^i -m_e^i\overline e_L^i e_R^i+ \textrm{h.c.}
\end{aligned}\tag6
$$
Here each term with an $_L$ or $_R$ subscript is a fermion of left or right chirality, while coefficients such as $m_u^i$ are effective masses that follow from the $\lambda$s by setting the Higgs field in (5) to its vacuum expectation value, viz. $\phi^0=\frac{v}{\sqrt{2}},\,\phi^1=\phi^2=\phi^3=0$.
Gauge bosons require a different treatment, viz. Eqs. (1)-(4) in the same source. Fermions can in theory be massive without violating gauge invariance even without a gauge boson. For example, the electron's electromagnetic Dirac Lagrangian $\overline{\psi}\left(i\gamma^\mu\left(\partial_\mu+qA_\mu\right)-m_e\right)\psi$ allows this. (Having said that, whether this works depends on the gauge group.)
By contrast, the photon $A_\mu$ can't just gain a mass term like that, because adding an $m^2A_\mu A^\mu$ term to $\left(\partial_\mu-iqA_\mu\right)\phi^\ast\left(\partial^\mu+iqA^\mu\right)\phi-\frac{1}{4}F_{\mu\nu}F^{\mu\nu}$ would break the gauge invariance. In fact, the photon is massless. The problem is the W and Z bosons are not, and giving them a gauge-preserving effective mass requires terms of the form $q^2|\phi|^2B_\mu B^\mu$. As with leptons, the mass is proportional to the Higgs vacuum amplitude.