The best way to learn navigation is to make frequent use of your gauges and build a mental "map" in your head as you go. Start by establishing an "out-in" line, and set the bezel on your compass to indicate the heading. For shore diving, stand on the beach and point the compass straight out. I like to set the bezel so that the double arrow is on north when pointing out ... like it's a "valley" going down. The single arrow is a "mountain" for when you're coming upslope. Do it the same way every time, so you get used to what you're seeing. On a boat, set "out" in your anticipated direction of travel away from the upline or anchor line, and "in" for the return. Once you drop down the line, and before you get going, look at your depth ... that's often an important piece of information to have if your intent is to return to the upline at the end of the dive (i.e. the boat's anchored).
Once you've established out and in, use that as your reference line for building your mental "map" as you proceed with the dive. Which direction are you traveling relative to that line? Are you to the right or left of the line? At what angle? For how long in terms of travel time? Now, for the return, if you're in terrain with a reasonable slope, all you have to do is remember which side of your "out-in" line you're on, and what your starting depth was. Go to that depth and turn in the direction of "home" (your anchor line or starting point). Maintain that depth ... eventually you'll swim to the line.
Keep in mind that slopes are not always steady ... depths can meander with respect to direction, just like hillsides do above the surface. Keep in mind that current means you'll move faster in one direction than you will in the other, and factor that into travel times. It's not an exact science ... and you'll improve with practice. But it'll get you close to your starting point.
The other thing that's really helpful is to make note of things you see that you're likely to remember, so that on the way back you can look for those things. It's not unusual to second-guess yourself once you're on the return, and seeing something you remembered seeing on the way out is a great way to sanity-check or make those small course-corrections that can become needed if the current's pushing your frame of reference.
The key is to establish that "out-in" direction, to look at your gauges frequently, and to keep in mind what your general direction of travel is relative to where you started. It's more than just using your compass ... your travel time and your depth are also useful pieces of information. Using them all, you will gradually become more proficient at "mapping" your dive as you go. It just takes practice.
... Bob (Grateful Diver)