The reason basil pesto turns brown is because of oxidation, which happens when chopped basil leaves meet air. To keep that lovely green color, just cover the pesto surface with a thin layer of olive oil before sealing it up.