Shelves are a simple thing, but unfortunately, not always a reliable thing. Under the pressure of books or dishes, shelves flex and sag, making them unsightly and unsafe. Torsion box to the rescue! Though torsion boxes are often used for tabletops, they make great shelves for the same reason: lightweight strength.
Step 1: Ribs and Skins
A torsion box is two thin layers (“skins”) with a grid (“ribs”) glued in between. This construction results a lightweight, but strong structure, which is why it's perfect for shelves, especially ones that will carry a lot of weight, or need to span a great distance. Your bedroom door is probably a torsion box, which is why it's much lighter than your solid-core front door, but maintains its shape even with a lot of movement. Hollow-core doors typically have ribs made of cardboard, in a honeycomb pattern, but the concept is the same. (sidenote: A door also makes a great workbench top, for the same reason.)
Step 2: Example
This desk that I built for a friend has a torsion box top. Because he wanted his piano to sit in a drawer like a computer keyboard, the desk needed to have approx. 60" clearance between the lower support cabinets. Even with thick, stable plywood, that distance puts the surface at risk of bending (deflection) under the weight of elbows, speakers, etc. So the top was built as a torsion box, and it's solid enough for me to stand on.
The second photo shows a glimpse of the inner ribs that were glued in. Because the strength comes from all the glue surface between the skins and the ribs, it's not necessary to half lap the ribs where they cross. Certainly there's no harm in doing half laps, but it's much simpler to glue up the ribs in one direction, then cut smaller pieces to fill in the other way. Don't get me wrong; the ribs should be cut to length, minimizing gaps, but the torsion box is incredibly forgiving of some internal sloppiness.
Another element to keep in mind is that the height of the ribs will contribute to strength. Thinner is not better here, so consider the trade off between aesthetics and function in your design.
Though not needed for the sake of strength, trimming out the torsion box with hardwood will give it a cleaner, more finished look. If you wish to mitre (45º) the corners, remember to measure each piece for the total length, including the trim on both ends. When in doubt, cut it longer than you need and adjust later with a hand plane and/or sandpaper.
Step 3: Shelf Installation Options
These shelves work best when they are installed against at least two surfaces. They will be strong as floating shelves against a single cleat, but when installed in a corner with at least two cleats, they'll be bulletproof (not literally... don't shoot it.)
Check out these great examples:
from YouTuber Ron Budman
Commercial versions often have metal tubing you attach to studs, but wooden cleats are just as strong, and easier to make yourself.