I know what you're going through, I am experiencing the same issue right now. I have been for a few days now, and I did last year when I was working on a project. There are times when you know you should be getting work done, maybe because you have people looking up to you or because of a deadline closing in on you. But you can't bring yourself to it. I spent hours scrolling through newsletters, tutorials, dev blogs and documentations, when I should have actually been writing code and putting work in. And when I do start, all it takes is a small bug in my code to make my shut down my laptop and browse reddit.
But I did eventually come out of it. Like you said, you have productive seasons. I also had one or two days in a week where I could sit for 8 straight hours and code. And the happiness and satisfaction I get after those 8 hours is just something else.
All I can say to you is that hold on to those productive days, and don't beat yourself up because of the unproductive ones. Take rest and chill.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.