Flies buzzing around your backyard can be unsanitary, unsightly and annoying, whether you're gardening, hosting an outdoor barbecue party or simply trying to relax outdoors. Ditch the bug spray and sticky traps, which rarely work in the long term. Instead, shoot down this airborne problem for good with some smart landscaping solutions.

compost in the garden
credit: Schlegelfotos/iStock/Getty Images
A poorly managed compost pile can attract dozens of flies.

Defend Yourself With Herbs

Instead of turning to chemical deterrents, go the all-natural route and take advantage of herbs that smell great to you but not to flies. Both lavender (Lavandula angustifolia) and basil (Ocimum basilicum) have pungent foliage that deters flies from making your garden their home. Lavender thrives in U.S. Department of Agriculture plant hardiness zones 5B through 8, and basil grows as a perennial in zones 10 and higher and as an annual everywhere else. Both plants prefer full sun and well-draining soil. Mix them into your border plantings and flowerbeds to keep pests at bay, or grow them in pots and move the pots wherever you need fly protection -- ideal if you regularly entertain outdoors and want portable fly defense.

Harness the Power of Candles

For fire-safe hard surfaces, such as a patio or outdoor table, create a cozy ambiance and a fly-free zone with candles or tiki torches. The flickering light adds life to any landscape, and the smoke from the flame deters flies, mosquitoes and other pests. Add extra fly protection by using citronella candles or torches -- citronella is an Environmental Protection Agency-approved bug repellant effective against flies.

Zap Away Your Worries

Bug zappers attract nearby flies and other flying insects and zap them dead. You can find bug zappers in many designs that can match most outdoor settings, whether your garden is rustic, modern or anywhere in between. For hassle-free fly protection, use a solar-powered lantern. Because it uses energy from the sun to run, there's no need to deal with tangled power cables in your garden.

Practice Safe Composting

Compost adds nutrients to your garden's soil, but it also often adds fly problems because the insects like to feed on the compost and use the compost as a breeding site. This tends to happen with compost piles that aren't maintained well, with the waste material not decomposing fast enough to stay hot and inhospitable to pests. Turning your compost pile every two days, shredding waste material into pieces that are 2 inches wide or smaller, and keeping the pile compact and contained can eliminate flies.

Tidy Up Your Yard

Some say cleanliness is next to godliness. In your backyard, cleanliness is definitely next to becoming fly-less. You can control most fly invasions by keeping your landscape clean, which eliminates the breeding ground for flies. Always keep trash in sealed trash containers. If you have pets outdoors, pick up after them when they relieve themselves. Clean up fallen debris, leaves, weeds and rotting fruit or vegetables in your garden. Maintain a tidy outdoor landscape, and you'll stay free of flies.