How do I keep motivation?

for almost a year now I’ve been working out and trying to lose weight and at times I’ve been successful and kept motivation going but then it died down and I stop doing it and gain back everything I lost and I can only imagine how much weight I could’ve lost by now since I’ve been trying to for a year if I keep the notify and I don’t want to wonder again in the future so does anyone know how to keep motivation?