How to stay engaged with writing (among other things)
Implement Pacing and Novelty
Being a good writer involves reading as much as writing. When writing any particular piece, I often burn out and need to divert my attention to an easier task. As apposed to jumping into a severe distraction (facebook, video games, a rich social life) I recharge while reading another writers work. I also have several things I could be writing at any one time, some of which have lower standards of quality than articles I intend to publish. I often switch to my Zettelkasten when I get burned out. My Zettelkasten—where this note resides—is exclusively intended for personal use, so I don't much care if my writing here is ungood.
If I absolutely must take a break, I try to do something productive, menial, and boring. Washing the dishes; doing laundry; working on my Anki flashcards. This way I can recharge while either completing a task that I would have needed to do otherwise, or I will abandon the task like the procrastinator I am and use writing as an excuse to delay whichever house work I don't feel like doing.
The most engaging video games I've ever played use a technique referred to as pacing—frequent shifts between different types of challenges, with varying degrees of difficulty—in order to keep players engaged. This same approach can be applied to writing manually. As long as you have several tasks that all contribute to the core goal of writing, and as long as those tasks feel different and vary in mental effort to perform, switching between these tasks at will can help to stay engaged.
Keep metrics, set binary goals, make them challenging
Writing is a muscle, one which does not develop naturally with age. Setting a goal ahead of time can help with engagement. The goal needs to have a very clear measurement for success, however, otherwise it will be too difficult to flout if you aren't feeling like engaging. For example, "I'm going to write five pages a day" is difficult to fake (assuming you don't get weird with fonts). But I'm going to practice writing every day leads to questions like "does a hundred words count?" This goal then needs to change the moment it becomes easy. Did you manage to write six pages? Good. You will write six pages a day from now on.
Split it up
Split writing up into as many different activities as you can, and get weird with it. I'll sometimes take one sentence and attempt to elaborate on it as much as possible. Sometimes I'll try to define all of my jargon—jargon: a term the reader might not know—without using any of the other jargon. Sometimes I'll write a draft as if I was about to die, and my last act on earth is to capture this knowledge in writing before my heart stops beating, making it much harder to write. Sometimes I'll find old notes, read them, and then rewrite them. Sometimes I'll edit the old notes if I'm feeling like some light editing. Sometimes I'll read other peoples work with the direct intention of producing new notes.
Do nothing else. Use a pomodoro timer if that's your thing. Use noise canceling headphones. Go to a library or coffee shops with minimal activities to distract you. See Deep Work.