Pulse the garlic scapes in a food processor until finely chopped, scraping down the sides once or twice.
Add the Parmesan, pine nuts, salt and olive oil, plus the lemon juice and basil if using. Process until thick and smooth, scraping down the bowl as needed.
Taste, then add more salt, lemon juice or basil if it needs it.
Refrigerate covered and use within 4 to 5 days, or freeze in freezer jars with 1/2 inch headspace. Thaw frozen pesto in the fridge and use it within 4 to 5 days. Serve hot or cold.
Notes
Yield: Two cups of 1-inch (2.5 cm) pieces takes about 20 to 25 garlic scapes. The recipe makes about 2 1/2 cups (600 ml), or 20 servings of 2 tablespoons (30 ml). Halve it for about 1 1/4 cups (300 ml), or double it for about 5 cups (1.2 liters).Substitutions: Cashews or raw sunflower seeds work in place of pine nuts, and sunflower seeds make it nut-free (check the package for a nut warning if you're cooking for an allergy). A dairy-free Parmesan-style cheese works in place of Parmesan.Storage: Keep fresh pesto covered in the fridge and use it within 4 to 5 days. For longer storage, freeze it in glass freezer jars or plastic freezer containers with 1/2 inch headspace, or in an ice cube tray and then a freezer bag. It stays safe as long as it stays frozen and tastes best within about 6 months. Thaw it in the fridge and use it within 4 to 5 days. There's no tested way to can pesto.