It is easier said than done.
Here is what works for me.
1/ Keep no more than 3 high value tasks on your to-do list. These tasks should take you close to your vision of your best life.
2/ Timebox each. Assess how much time each of these tasks will take and use 15 mins or 30 mins blocks to note how much you’ll take for each. Then commit to completing each during the time you noted for that task.
3/ Work on these high value tasks when your energy levels are high. It is easy to get distracted when your energy levels are low.
4/ Use a timer and don’t stop working until the timer goes off. If a task will take longer than 45 minutes then pause the timer when you take a break and switch it on when you are back from the break.
5/ Put the phone on flight mode, away from sight when working on your core tasks.
6/ Use different devices for work and entertainment. It trains your brain to work on your work device without any effort.
7/ Try virtual coworking. I haven’t done it myself but have heard good things about Focusmate.