First it's important to have regular moderate exercise- at least 30 minutes in a day. Second use bed only for sleep. Do not sit there and watch TV etc. Third, avoid use of TV, mobile near bedtime. The white light can impair release of the sleep hormone. Fourth keep lights down low in the evenings instead of bright Tubelight. Read before sleeping. If you do not get adequate sleep- still make up at the same time. Avoid thinking about it too much as the thoughts can further maintain the insomnia.
Learn to write the thoughts- e.g. I'll have a bad day, I hardly slept. Change the thoughts to more appropriate ones. e.g. I didn't get much sleep but it's ok. It's a phase. It's not something I did deliberately. Relax.
Along with exercise try Yoga nidra etc.
Next Steps
If it still doesn't help meet a sleep specialist or doctor