The stock market is at or near all-time highs today, making this one of the longest bull markets on record. It's not easy to find stocks that are trading at attractive prices and offering robust dividend yields. But there are opportunities if you are willing to look. For example, Franco-Nevada Corporation (TSX:FNV) and General Mills, Inc. (NYSE:GIS), down more than 20% each, appear to be great opportunities today.

1. The safety-first gold investment

During Franco-Nevada's fourth-quarter 2017 conference call, CEO David Harquail was asked about the likelihood of the gold streaming company using its balance sheet more aggressively. His response: "We still want to be the risk-off gold investment." In other words, little to no debt would remain the norm for Franco-Nevada. 

The word dividend over a jagged arrow that is pointing higher

Image source: Getty Images.

That puts the company's 26% price decline since late 2017 in a slightly different light. The company, quite literally, has no long-term debt on its balance sheet. And Franco-Nevada's roughly $70 million in dividends paid through the first half of 2018 was handily covered by the $369 million in free cash flow generated by the business over that span. This isn't a company that's at risk of financial ruin today, despite a deep stock price decline that pushed the yield up to 1.5% -- toward the high end for the company's historical range. The divided, meanwhile, has been increased each year since Franco-Nevada's 2007 IPO.   

So what's going on with the stock? First, Franco-Nevada's top and bottom lines are driven by commodity prices, and gold -- 67% of second-quarter revenue -- has been weak. Second, some of its gold mine investments are facing headwinds, which has resulted in a decline in gold production through the first half of 2018. However, Franco-Nevada took advantage of the last oil downturn to diversify its business into the oil space using the same streaming and royalty model that it uses in precious metals. That shift has helped it to offset the gold weakness, proving the company's safety-first approach is working. In fact, despite some headwinds, earnings were up 25% a share year over year through the first six months of 2018.   

Franco-Nevada's yield may not be huge, but it is high for the company. And the stock is a great way to add some gold exposure to your portfolio, just in case the broader market heads lower. If that happens, gold, a hard asset, could rise as investors seek safe-haven investments. Moreover, the company's ability to navigate the current headwinds it's facing is proof of the value of its conservative model. Now is a good time to take a look.

2. This too shall pass

General Mills is one of the world's largest packaged-food companies, with iconic brands and incredible distribution muscle. Still, packaged food is a tough business today, as customer tastes are shifting toward foods seen as fresher and healthier.

There's no question that General Mills has been struggling. For example, in fiscal 2017, seven of the company's nine core segments saw market-share losses. Revenue, meanwhile, fell each year between 2014 and 2017. And in fiscal 2018, the company made an $8 billion investment in the pet food sector, pushing long-term debt up to $12.6 billion, or roughly two-thirds of the capital structure. Investors are worried it overpaid. To add insult to injury, the food maker is also facing cost headwinds, including input cost inflation and rising transportation costs.   

GIS Chart

GIS data by YCharts.

It's no wonder the stock is down 40% from its mid-2016 highs. In fact, it's down nearly 28% this year alone. The 4.5% yield is higher than it was during the 2007-9 recession. You have to go back to the 1990s to find a time when General Mills' yield was this high. Yes, there are headwinds, but this looks like a good opportunity for long-term dividend investors to jump aboard.

Why? Because there's reason for optimism. In the first half of fiscal 2018, General Mills was able to gain share in five of its nine core segments, showing that its efforts to adjust with the shifting market was bearing fruit. And it has only gotten better. In the second half of fiscal 2018, it gained share in seven segments, and in the first quarter of fiscal 2019, it gained share in eight. Revenue, meanwhile, has been higher year over year in each of the last four quarters. And while debt is elevated today, the company covered interest expense by more than four times in the first quarter. That's plenty of leeway for a company that sells lots of small, necessity products to lots of different customers. It has the financial strength to muddle through this tough spot.   

You have to take the long-term view with General Mills today. A ship this size doesn't turn quickly. But it does look like the ship is turning. And you can collect a fat yield while you wait for better days.

Bears in bull land

It isn't easy going against the grain. But with the market at or near all-time highs and the current bull market getting long in the tooth, I'm loath to invest in high-flying stocks. Which is why I'm attracted to down-and-out General Mills and Franco-Nevada. They've already been hit hard, but it appears that they're doing reasonably well dealing with the headwinds they face. That's an opportunity to add great names on the cheap, and collect historically high dividend yields, in an otherwise rich market.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.