Nomenclature: Yang-Mills theory vs Gauge theory
Very briefly, a classical theory is a gauge theory if its field variables $\varphi^i(\vec{x},t)$ have a non-trivial local gauge transformation that leaves the action $S[\varphi]$ gauge invariant. Usually, a gauge transformation is demanded to be a continuous transformation.
[Gauge theory is a huge subject, and I only have time to give some explanation here, and defer a more complete answer to, e.g., the book "Quantization of Gauge Systems" by M. Henneaux and C. Teitelboim. By the word local is meant that the gauge transformation in different space-time point are free to be transformed independently without affecting each others transformation (as opposed to a global transformation). By the word non-trivial is meant that the gauge transformation does not vanish identically on-shell. Note that an infinitesimal gauge transformation does not have to be on the form
$$\delta_{\varepsilon}A_{\mu}(\vec{x},t) = D_{\mu}\varepsilon(\vec{x},t),$$
nor does it have to involve a $A_{\mu}$ field. More generally, an infinitesimal gauge transformation is of the form
$$\delta_{\varepsilon}\varphi^i(x) = \int d^d y \ R^i{}_a (x,y)\varepsilon^a(y),$$
where $R^i{}_a (x,y)$ are Lagrangian gauge generators, which form a gauge algebra, which, in turn, may be open and reducible, and $\varepsilon^a$ are infinitesimal gauge parameters. Besides gauge transformations that are continuously connected to the identity transformation, there may be so-called large gauge transformations, which are not connected continuously to the identity transformation, and the action may not always be invariant under those. Ultimately, physicists want to quantize the classical gauge theories using, e.g., Batalin-Vilkovisky formalism, but let's leave quantization for a separate question. Various subtleties arise at the quantum level as, e.g., pointed out in the comments below. Moreover, some quantum theories do not have classical counterparts.]
Yang-Mills theory is just one example out of many of a gauge theory, although the most important one. To name a few other examples: Chern-Simons theory and BF theory are gauge theories. Gravity can be viewed as a gauge theory.
Yang-Mills theory without matter is called pure Yang-Mills theory.
What I've usually heard in practice is that a Yang-Mills theory is a gauge theory with a non-Abelian gauge group. That would disqualify classical E&M, for example, where the gauge group is $U(1)$.
Wikipedia has a slightly more restrictive definition, saying that a Yang-Mills theory is a gauge theory based on $SU(N)$ specifically.
I'm not quite sure which definition to go with. It probably depends on who you're talking to. Regardless, the only distinction I'm familiar with is based on the nature of the gauge group and has nothing to do with whether there happen to be matter fields or not.
"Yang-Mills theory" is pretty much equivalent to "gauge theory". You could say gauge theories are more general, since we usually think of Yang-Mills theories as being gauge theories of SO or SU groups, or sometimes one of the other classical lie groups. But you could make a distinction by saying something like "gravity is a gauge theory but not a Yang-Mills theory," since its gauge group would be local Poincare transformations.
The term you're thinking of without matter is probably "pure Yang-Mills theory" or "pure gauge theory."