Get a good solid 8 hours of sleep. Sometimes a lack of motivation is is simply fatigue. It makes my work day drastically different.
Don't try and cheat it either by sleeping less using caffeine to feel awake.
P.S. I am saying this as I bring on another all nighter, doing work I don't really enjoy. ;) I bought a Mi Band to track my sleep, though! I highly recommend it. If you measure it, it will improve.
I actually wrote a post 3 years ago about this, here's the gist of it
1. Get solid sleep time
2. Exercise
3. Stay Hydrated
4. Pomodoro
5. Block all distractions out, I use `get-shit-done`. basically `sudo get-shit-done work` will block all distracting websites.
Most of all though, if you get the chance to pick your own tasks, just move to something that's more interesting to you.
Since I switch a lot between operations (chef etc..), backend and frontend, sometimes just switching to another task helps.
Hope this helps, just my 2 cents