All that glitters isn’t gold—at least for the investors who are eschewing the precious metal in favor of the companies that mine it. After years spent in the shadow of gold, miners are back in favor, driven by stronger earnings and cuts to mining costs. The NYSE Arca Gold Miners Index, which tracks 39 gold-mining companies, has soared 26% so far this year, compared with a 8.9% rise in gold and a 4.5% increase in the S&P 500.