Fresh basil contains polyphenols that oxidize rapidly when exposed to air, and it's a process that's almost impossible to stop completely, but you can slow it down quite a bit. Whoever tells you that the dark color doesn't affect the taste is right, but I get it - black pesto loses a lot of visual appeal.
The most effective move is to cover the pesto with a layer of good olive oil - at least half a centimeter thick on top of the surface. It creates a barrier against air, and even if the pesto underneath changes color slightly, what you see stays green. Keep the jar well sealed in the fridge, and before using it you can either mix the oil into the rest or remove it if you prefer. Then there are the small details: when you make the pesto, add fresh lemon juice while you're doing it - the acidity slows down oxidation. Use a blender as little as possible because heat speeds up the process, and if you can crush the basil with a mortar it's even better. Finally, freezing it in small portions in containers or freezer bags works really well - frozen pesto keeps its green color and flavor intact for months, and you thaw it when you need it.