Remember one thing when you consider consumer staples makers: You "need" the products they sell. That's particularly true when it comes to food-focused consumer staples companies like General Mills (GIS 0.01%), PepsiCo (PEP 0.99%), and Hershey (HSY 1.47%).

Here's why each one of these dividend stocks is worth buying and holding for 20 years, or more, right now.

A person looking at a box in a grocery store.

Image source: Getty Images.

1. General Mills is shifting with the times

General Mills makes food products like cereal, snack bars, pet food, and baking products. It owns a collection of brand names that you likely know well, including Blue Buffalo and Cheerios. The brands and products it sells are staples in grocery stores and in consumer cupboards. It's highly unlikely that General Mills will suddenly go out of business anytime soon.

That said, right now the company is facing some headwinds. Consumer buying habits are shifting, and some buyers are pulling back on spending. That has left General Mills' financial results weak. Sales and earnings fell year over year in the fourth quarter of fiscal 2025. The company's fiscal 2026 outlook was a bit weak, too.

But management is doing what it can to adjust, including changing formulations to match current trends, adjusting its brand and product portfolio, and trying to keep a lid on costs. These are the right moves and, in time, they will likely lead to General Mills getting back on track. It always has in the past.

While General Mills' stock is out of favor, you can buy it at an attractive 4.8% yield. That's near the highest levels in the company's history. If you like income and think long term, General Mills should probably be on your buy list today.

2. PepsiCo has industry-leading brands

General Mills is a good company with industry-leading brands, but PepsiCo's brands stand out even more. It's the No. 2 beverage company and the No. 1 salty snack maker. It also makes packaged food products that compete with companies like General Mills. The problem for PepsiCo is that customer tastes are shifting, and it is out of step with its customers. The company is working on the issue -- it recently bought a Mexican-American food business and a probiotic beverage company. Both are more in line with current trends.

Sure, PepsiCo's recent financial results aren't that great, and they lag those of its closest peers. It's OK -- that happens even to well-run businesses. PepsiCo didn't achieve Dividend King status by accident, and it has muddled through hard times before. It's highly likely that it will do so again.

In the meantime, you can collect a historically high 3.9% dividend yield. If the dividend history here is any guide, you'll end up a long-term winner if you're willing to step in while the rest of Wall Street is selling.

3. Hershey's cocoa problem makes it hard to love

Hershey is the most difficult story to appreciate here for two reasons.

First, while it makes food, the most important product it sells is chocolate. That's not a necessity, even though people love the affordable indulgence. Second, the biggest headwind for the business is a shocking rise in the price of cocoa, a key ingredient in chocolate.

Cocoa comes from trees, so it could take some time before high prices lead to changes in the industry. That's why investors have sold Hershey stock hard, leading to a historically high 2.9% dividend yield.

Just how bad is it? Despite increasing prices and the expectation of sales growth in 2025, Hershey is projecting rising costs to lead to a roughly mid-30% drop in earnings in 2025. And given the nature of cocoa, the pain could linger for a bit.

There's a good reason why investors are negative on the stock. But if you can stomach some near-term uncertainty, the long-term picture is likely to be continued and growing demand for the affordable luxuries that Hershey sells.

You need and want what they make

It is hard to suggest that chocolate, soda, or cereal are life necessities. You can certainly eat and drink other things. But these consumer staples giants have long delivered the food items that people want to buy. That will be just as true in one year as it is in 10 years or 20 years. The headwinds they face today aren't likely to change anything about the nature of these businesses, even if the companies do need to adjust to better align with current trends. The truth is that they've all done that many times before.

Given the historically high yields on offer from General Mills, PepsiCo, and Hershey, buying and holding for decades is probably a good call for even the most conservative dividend investors today.