Pesto is thought to have two predecessors in ancient times, going back as far as the Roman age. The ancient Romans used to eat a similar paste called moretum, which was made by crushing garlic, salt, cheese, herbs, olive oil and vinegar together. During the Middle Ages, a popular sauce in the Genoan cuisine was agliata, which was basically a mash of garlic and walnuts, as garlic was a staple in the nutrition of Ligurians, especially for the seafarers.
The introduction of basil, the main ingredient of modern pesto, occurred in more recent times and is first documented only in the mid-19th century. Although likely originating from and being domesticated in India, basil took the firmest root in the regions of Liguria, Italy, and Provence, France. It was abundant in this part of Italy, though only when in season, which is why marjoram and parsley are suggested as alternatives when basil is lacking .
Pesto is traditionally prepared in a marble mortar with a wooden pestle. First, garlic and pine nuts are placed in the mortar and reduced to a cream, and then the washed and dried basil leaves are added with coarse salt and ground to a creamy consistency. Only then is a mix of Parmigiano-Reggiano and Pecorino added. To help incorporate the cheese a little extra-virgin olive oil is added. In a tight jar (or simply in an air-tight plastic container), covered by a layer of extra-virgin olive oil, pesto can last in the refrigerator up to a week, and can be frozen for later use.