"Bonk is a funny name for a terrible feeling, when suddenly there’s nothing left in the tank, the legs turn to jelly, and getting to the finish or just back home becomes an altogether supreme effort of will."
(bikeradar.com)
So just don't bonk! And it's not complicated - you simply need to eat and drink reasonably before and during the ride. In other words, don't start a new diet when getting ready for a ride!
There's lots of information on cycling nutrition and hydration on the internet. But for a thorough assessment of your dietary needs, consult a professional.