Fresh is best, but many herbs can be frozen with success. Here’s how:
When color is important, as in making pesto, blanch herb leaves before freezing: Immerse leaves in boiling water just until they turn bright green, 23 seconds. Immediately plunge them into ice water until completely cold. Drain. Spread leaves on towels and blot dry. (If color is unimportant, simply rinse herbs and let drain on towels until dry.)
Lay herbs in single layer on baking sheets. Freeze on pans just until rigid, about 1 hour.
Quickly transfer herbs to small self-sealing freezer bags and squeeze out excess air. Seal and return to freezer. Use as needed, returning remaining herbs to freezer immediately. Herbs can be frozen for up to a year, but flavor will diminish with time.