I struggled with this, too, especially since my pantry shelves are about 18-20 inches deep (think coat closet that is deeper on one end). I wanted to be able to quickly access things, and glass jars wouldn't do the trick. I got some clear plastic bins that will fit 2 to a shelf, side by side, plus one sideways across the back. I organize my boxed and bagged goods by "type" and use a bin for each -- pasta boxes and bags in one, rice and noodle mixes in another, baking mixes in a third, baking goods (brown sugar, powdered sugar, nuts, choc chips., etc) in another. Extras or goods used less frequently go in the bin that goes across the back, as back-up. I've got 3 shelves organized like this, with a supply of paper towels above and a drawer unit with pull-out baskets is below. Shelving above is open ventilated with a plastic liner insert, for cleaning. For the drawers, I've used a hard top surface, with mesh pull-outs, in both narrow (fits standard cans on their sides, labels up) and deep. On the opposite end, I placed rails with baskets in a wall unit and put an extra wall unit in-between, off-set to allow for the drawers to be pulled out. I also wound up adding a door unit with baskets for additional storage. My home canned goods are most often in the wall baskets.
Because of the unique size of the pantry closet, I customized an Elfa Shelving system from The Container Store (
https://www.containerstore.com/elfa/index.htm). I liked this system because I could purchase the drawers and baskets individually and could modify the set-up as needed to better suit my needs. Right now, I have one spare large bin for the pull-out drawers, and one additional long deep wall-unit basket. But, should I find that I want to add an extra basket, or swap out two narrow drawers for a deep one, I can easily make that change.
While Elfa is not cheap, they have several BIG sales throughout the year, making their systems more affordable, and they often include free installation with their sales. I'm sure there are similar systems out there, but this is the one that met my needs.