So, you’re ready to start a new exercise routine. Got your kickin’ pair of athletic shoes? Check. Got a new eco-friendly water bottle? Check. Got something to nibble on before you start working out?

Say what?

That’s right — food needs to be part of your exercise “gear.” Knowing what to eat before and after you exercise can be the difference between meeting your fitness goals and falling headlong into a tub of gelato by nightfall.

The goal is to fuel your fitness, to stay energized without eating so much that you upset your stomach. If you are always pushing yourself to work out when you feel pooped, it’ll be tough to stick to the plan over time.

“If you haven’t eaten in a long time, your body is in a fasted state,” said Nancy Cohen, a professor in the department of nutrition at the University of Massachusetts in Amherst.

“Normally, your body will use glucose for fuel and begin to break down muscle glycogen to deliver the glucose your body needs for exercise. In a fasted state, the muscle glycogen will be depleted sooner. Your body will then turn to breaking down fats for the energy it needs.”

But you don’t want to wolf down a whole cheeseburger, either. A snack packed with fiber-rich carbs and protein around 30 to 60 minutes ahead of a workout is just about perfect. Think a small snack, maybe around 200 calories.

And tailor the food to the activity. If you are lifting weights to build strength, go with protein, such as Greek yogurt, almonds or string cheese. If you are breaking a sweat with cardio, complex carbs such as raisins or string cheese might be ideal.

What you eat right after exercising also is key to getting in shape. If you are trying to lose weight, you don’t want to find yourself famished by dinnertime, which may lead to poor choices (hello, pizza delivery).

Instead, keep your appetite in check. Nosh on a healthy post-exercise appetizer, such as apple slices with peanut butter, that keeps you going and helps replenish the body so you’re not totally wiped out. And don’t forget to rehydrate.