It’s the first rule in The Hitchhikers Guide to the Galaxy and it’s also the first rule if you get lost hiking.
According to the US Forest Service, you need to stop the second that you realize that you are lost and remain calm and positive.
Think about how you got to this spot. Do you see any landmarks that might give you a sense of direction?
If you have a compass on you, then walk towards the direction that you will need to head for.
If you are not confident in any of your plans, then the best option is just stay where you are.
For this reason, it’s important that whenever you are hiking, you should take extra water and food with you. This way, if you do get lost, you’ll have backup reserve of necessities. Also, make sure to always tell someone where you plan on hiking, even if it’s just a short trail.