This deceptively simple strategy is probably the most effective.
When you notice your thoughts wandering astray, say to yourself
"Be here now"
and gently bring your attention back to where you want it.
For example:
You're studying and your attention strays to all the other homework you have, to a date, to the fact that you're hungry. Say to yourself
"Be here now"
Focus back on subject with questions, summarizing, outlining, mapping, etc. and maintain your attention there as long as possible. When it wanders again, repeat
"Be here now"
and gently bring your attention back, and continue this practice, repeatedly. It will work!
Do not try to keep particular thoughts out of your mind. For example, as you sit there, close your eyes and think about anything you want to for the next three minutes except cookies. Try not to think about cookies...When you try not to think about something, it keeps coming back. ("I'm not going to think about cookies. I'm not going to think about cookies.")
You might do this hundreds of times a week. Gradually, you'll find that the period of time between your straying thoughts gets a little longer every few days. So be patient and keep at it. You'll see some improvement!
Do not constantly judge your progress. Take it easy on yourself. Good practice is enough to say that you did it, and that you are on the road. The mind is always different and the practice unfolds over time with many ups and downs.