Going to sleep at the same time, and waking up at the same time is very important. Regular exercise. Eliminating alcohol/drugs, including caffeine. A good healthy diet...
As someone who occasionally struggles with insomnia, I highly recommend the Insomnia Coach App for iOS or Android. It’s entirely free (no ads or in-app purchases) and based on Cognitive Behavioral Therapy. It was developed by the US Department of Veterans Affairs, but it’s available and applicable to anyone who has trouble sleeping. It has guided meditation and other tools to help you sleep or identify causes of insomnia.
It requires some effort on your part: you follow a 5 week training plan and keep a sleep diary throughout. However the effort is minimal and again, it’s free. Following the sleep plan significantly improved the number of nights that I have good sleep.
Sleep advice is like love advice, it can never be applied universally. But back when I was learning the languages I now know, practicing them as I drift off into sleep not only seemed to be good for sleep but also the language learning process. So... maybe choose a language? Just throwing that out there.
A while back I realized there was a particular topic I could ponder and I'd fall asleep. For a few years, I was able to konk right out by returning to that topic. It doesn't work anymore, but maybe that's just because I haven't found the next sleepy topic.
Some good suggestions here. But if you've been battling this for ages, it might be time for a sleep study? You may need a referral from your family doctor for this, but it's generally not hard to get, and the sleep lab will be able to tell you if you have any bio-mechanical issues like sleep apnea, restless leg syndrome, etc. There are all sorts of things that can mess up sleeping. Also, it's a rapidly evolving field of medicine, so even if you had one done years ago, it might be worth a revisit?
There is no one-fits-all golden answer when it comes to sleeping but reducing heavy foods, any stress and overstimulation for at least two hours before planned bed time can help or be at least some form of a start..
If it is a problem with falling asleep, when you are lying for some prolonged time already — try standing up, doing some simple stretches, maybe drink water, slowly walk around, visit the bathroom and empty your bladder (don’t turn on too many lights etc.), you can even try some breathing exercises and then just try again.
Many people have a big problem with proper “coming back from work”, like reading some work related e-mails or chats / groups and so on — this can really harm your night / resting time. Make a holy boundary, cut-off time for those things or just fully turn off your phone and put it out of reach. If there are things like plans for the next day, some project that you need to do or a big deadline, physically write all this stuff that occupies your mind, “do the laundry, take the trash in the morning, call the manager and reply to X and Y about Z” — whatever fits your bill, write it down, put it on your desk or on a fridge — make sure that you feel it, do it slowly, be like “I am securing my plans because they are important to me and now there is no need to keep them in my mind, they will wait for me in the morning, right here” or something close to that.
One thing I haven't seen mentioned yet is to try and build up a pavlovian association with bed/bedroom = sleep. Don't do any mentally stimulating tasks while in your bed or even bedroom - no TV or youtube, no mindless phone scrolling, no gaming, etc. Bedroom should be for sleep and sex, and that's it. If you cut everything else out for a while, your brain will much more strongly associate bed(room) with sleepytime.
Other things people have mentioned are valid too. Consistent sleep schedule, don't eat/drink/exercise for 2-3hrs before bed, etc.
Figure out whether your circadian time is set for early morning (~5AM wake up time), day (~10AM wake), or night (~2PM wake). Despite what most people think, it's incredibly hard for one type to adapt to another.
Scientifically? No clue. But I figured out I was a night owl by the sheer fact that going to sleep at 5-6 AM to wake up at 12-2PM makes me feel well rested, whereas literally no amount of sleep will make me feel well rested if I have to wake up at 7-8.
I know that mine is a night one because I worked evening/nights for like 10 years and felt great. I've been working a 9-5 for about 4 years now and have learned to pretend I'm functioning on about 4 hours sleep per night. Sucks.
That's always going to cause problems. More caffeine takes longer to fade from your system.
I've gotten the best results from limiting caffeine intake to before lunch, and just accepting that I'm going to be tired in the afternoon. I need that tired period of time in order to sleep well.
Lights: Switching to light sources/bulbs with lower brightness/warmer light temperature (lower Kelvin/K-value) 3 hours before bed. (Light affects our sleep-wake cycle, aka the circadian rhythm. Our brain processes bright light as "the sun is still up so it's not time to sleep yet")
Screens: Gradually dimming electronic screens until bedtime (Computer: using F.lux and lowering the brightness gradually in the graphics card's control panel. Phone: with a built-in Night/Dark Mode option that you can schedule or by using an app like Twilight). // Don't take your devices to the bedroom, or keep them far away from the bed and set them on silent/shut them off.
Try not to sleep for more than 8 hours so you'll need the sleep the next night.
Sleeping in a closed and completely dark room (including covering LED lights on electronics, or using a face mask) with something that makes a white noise (fan/air purifier/etc.)
Food: Having a light meal 3-3.5 hours before bed and light snacks 1.5-2 hours before bed, to not put the body into overdrive digesting a heavy meal or cause heartburn/indigestion, and also to not go to sleep hungry and get distracted by that.
If you sleep on your stomach with your head to the side, you can use a thin and narrow side pillow (but firm) along your torso to support your shoulder on the side that your head is pointing to. (you can also use a thin pillow for your head to not strain your neck/spine - there are ones made for kids if needed)
A sleep tracker really helped me. The worst thing about sleeplessness is the fear of sleeplessness. Seeing that you did actually sleep, even though it felt like you were lying awake all night, really helped me put things into perspective. Also, it'll show everything you do wrong, like go to bed too late, drink etc. That way you always know why things aren't going well and you can also see how being disciplined helps.
Avoid doing things like reading, watching TV, or phone scrolling in bed. Make it a habit to turn out the lights within a few mins of laying down if not immediately.
Also use light filters so you're not exposed to blue light near bedtime. I think these two things have helped me basically turn sleeping into my superpower.