In the bowl of a food processor, combine the basil leaves, pine nuts or walnuts, and garlic. Process until everything is combined (it will still be chunky). Stop the processor, remove the lid, and scrape down the sides of the bowl.
Replace the lid and remove the processor's plug in order to pour the olive oil directly into the mixture. Slowly drizzle in the olive oil and continue to process until all of the oil is incorporated.
Stop the processor and add the salt and Parmesan cheese, if using. Pulse a few times to combine, then use pesto immediately. Pesto says fresh, covered tightly with plastic wrap pressed to the surface in the refrigerator up to 4 days. Pesto freezes very well. Wrap tightly with plastic wrap pressed to the surface, up to 3 months. Thaw in the refrigerator.
Notes
Parmesan cheese: this is a traditional ingredient in pesto, but omitting it will make this pesto vegan as well as dairy free.
All nutritional values are approximate and provided to the reader as a courtesy. Changing ingredients and/or quantities will alter the estimated nutritional calculations.