Doors and walls share a common purpose - creating a barrier. They differ in one respect, walls are permanent while doors are not. The lack of permanence can create some issues usually solved with latches, doorknobs and locks. Backyard gates and shed doors are usually kept shut with latches. To keep a door closed, you may be able to latch the door closed without running to the hardware store.
Hook and Eye
If you have either a latch hook and eye hook or two latch hooks and an S-hook on hand, you have everything you need for a basic latch. Install the two eye hooks, or the base of the latch hook, on level with each other, one on the door frame and the other on the door. Attach the hook or S-hook and clip the two eye hooks together. If you're using an S-clip, crimp one end of the hook closed so that it doesn't fall off. These work by creating a pulling force on two fixed points.
A wood block, a screw and a pair of washers can make a simple latch that works best on a turning door that opens outward. Because the door only opens one direction, you'll need to close that way off. Measure the center point of the block, drill through that and attach the block to the door frame.
An alternate design places an L-shaped wood block on the door frame with the longer side outward, while having a narrower rotating part that fits into the notch on the wall. To adapt this for a sliding door, you'll need a wood block with a hook on the end that can clip onto the frame block.
A sliding latch is a really common design, adapted into deadbolt locks. They are usually made out of metal, although wooden ones do exist. Sliding latches work best on rotational doors and work in a different direction than the door. There is a loop of metal or wood on the door that a latch mechanism slides into from its position looped also onto the door. You can make one out of wood by making three identical C-shaped wood blocks and a slide latch that fits through the hollow part of the C with a handle about two thirds of the way down. Attach one loop to the door frame and one to the door in the closed position. Slide the latch between them. Pull the latch out so that it's not locking the door closed anymore and attach the third C block.