With magnetism, the Gibbs Free Energy is $F-HM$, where $F$ is the Helmholtz Free Energy, $H$ is the auxiliary magnetic field, and $M$ is magnetization.
Why is this? Normally, in thermodynamics, we Legendre Transform the various free energies into each other to maximize the global entropy. In these cases, we subtract $TS$ when we are imagining a system exchanging heat with a thermal reservoir (i.e. heat bath at constant temperature $T$), add $PV$ when we exchange volume $V$ with a constant pressure reservoir at pressure $P$, and subtract $\mu N$ when we exchange particles with a chemical reservoir at constant chemical potential $\mu$.
In every other case, we exchange heat, volume, and particles with the reservoir. How do we justify writing $G=F-HM$. Though it is true that $H$ is maintained constant, we don't exchange magnetization with a "magnetic reservoir".
Best Answer
According to the first law of thermodynamics
\begin{align}U=TS+YX+\sum_j\mu_jN_j.\end{align}
Where $Y$ is the generalized force, $dX$ is the generalized displacement.
Helmholtz Free Energy
\begin{align}F=U-TS=YX+\sum_j\mu_jN_j. \end{align}
Gibbs Free Energy
\begin{align}G=U-TS-YX=\sum_j\mu_jN_j.\end{align}
Therefore that
\begin{align}G=F-YX.\end{align}
In your case, $Y=H$, $X=M$, so we get
\begin{align}G=F-HM.\end{align}
You can see the textbook:
A Modern Course in Statistical Physics by L. E. Reichl, 2nd, ed (1997), p23, 42, 45.