Minecraft wiki entry for Navigation, associated text: Torches: Place all the torches on one side of the cave when entering a new passage. Follow the torches on the other side to find the exit. When the cavern forks, explore the left-most path first, then move to the right until the entire fork has been explored. Torches can also be placed to point back toward the exit.
Signs: Placed at intersections and marked with ASCII arrows or messages can help keep track of exits, unexplored areas, and more. Signs are cheap, but they stack only to 16, which is why it's always a good idea to have a stack of logs and a crafting table on every mining trip.
Cobblestone: Rarely occurs naturally, can be used to mark sections that have already been mined. Additionally, arrows made of cobblestone in the floor or walls of caverns can point toward the exit.
Jack o'Lanterns: Can be placed at intersections with the face pointing toward the exit. This doubles as a light source and a direction out. In cases where there is one path on top of the other one, place the jack o'lantern higher (using piles of gravel or some other temporary block to place it on top of) to indicate the exit is the upper path.
Netherrack: Conspicuous, easy to obtain, and rarely naturally appears in the Overworld. Netherrack can also be lit to create light and mark completed areas.
Minecart Rails: Can be used both to mark paths and to transport the player.
Wool: Different colors can be used to signify different things, such as completed tunnels, unexplored areas, and exits.
Redstone: Lines and arrows can be made from spare redstone dust, and placing redstone torches nearby can make a lit trail that fades away. This can be used as a directional hint.
String: Can be placed on the ground to leave a trail behind you.
Magenta Glazed Terracotta: The arrows in the design can be used to point you in the right direction.
Mushrooms: Can be found in caves and can be used to leave a trail.
Quartz stairs: Can renamed and put on glowing item frames so when you move your crosshairs over the arrow you make from turning the stair, text can appear and lead you to where you want to go. : Note, this can only work on 1.17+ and these arrows can be seen in absolute darkness but don't actually give off light