How do you avoid getting distracted while studying?

There are so many distractions online like social media and memes... how do you avoid getting distracted while you are studying or writing a paper?