In this paper, we study the following Kazdan–Warner equation with a sign-changing prescribed function h \(\begin{aligned} -\Delta u=8\pi \left( \dfrac{he^{u}}{\int _{\Sigma }he^{u}}-1\right) \end{aligned}\) on a closed Riemann surface \(\Sigma \) whose area equals one. The solutions are the critical points of the functional \(J_{8\pi }\) which is defined by We prove the existence of the minimizer of \(J_{8\pi }\) by assuming \(\begin{aligned} \Delta \ln h^++8\pi -2\kappa >0 \end{aligned}\) at each maximum point of \(2\ln h^++A\) , where \(\kappa \) is the Gaussian curvature, \(h^+\) is the positive part of h and A is the regular part of the Green function. This generalizes the existence result of Ding et al. (Asian J Math 1:230–248, 1997) to the sign-changing prescribed function case. We are also interested in the blow-up behavior of a sequence \(u_{\varepsilon }\) of critical points of \(J_{8\pi -\varepsilon }\) with \(\int _{\Sigma }he^{u_{\varepsilon }}=1, \lim \limits _{\varepsilon \searrow 0}J_{8\pi -\varepsilon }\left( u_{\varepsilon }\right) <\infty \) and obtain the following identity during the blow-up process \(\begin{aligned} -\varepsilon =\frac{16\pi }{(8\pi -\varepsilon )h(p_\varepsilon )}\left[ \Delta \ln h(p_\varepsilon )+8\pi -2\kappa (p_\varepsilon )\right] \lambda _{\varepsilon }e^{-\lambda _{\varepsilon }}+O\left( e^{-\lambda _{\varepsilon }}\right) , \end{aligned}\) where \(u_\varepsilon \) takes its maximum value \(\lambda _\varepsilon \) at \(p_\varepsilon \) . Moreover, \(p_{\varepsilon }\) converges to the blow-up point which is a critical point of the function \(2\ln h^{+}+A\) .