How do you cope with distractions?

I'm self learning web development and however much I may want to do it, I get so burnt out quickly and end up doing nothing the entire day. I have trouble with locking in and actually getting some studying done. For anyone who has gone through this, what is your method of staying on a path and actually being able to study web dev or any other languages, for a long time

(For context, after 30 minutes I start walking around my house, get food watch tv and forget about what i was doing till reality hits)