For runners, the nail gets damaged and comes off due to ‘microtrauma’ experienced when the nail hits the top of the shoes during the stride. And as there are quite a few strides per run it’s bound to happen to some!
If this happens then you should try to protect the area when going running or walking long distances. Try a padded plaster to soften the impact the area receives, as long as it doesn’t cause any pain or rubbing. If you’ve just damaged half the nail and some of it is still hanging on to your toe, then you should try to trim away the damaged part so it doesn’t catch on anything. Then, in both scenarios, let the rest of the nail/the new nail grow back.
To prevent further lost toenails have a think about why your nail is rubbing against your shoe in the first place. Are the tendons in your foot tight and forcing your toe to curve up unnecessarily high? Try putting the tops of your feet flat on the ground then slowly sitting back on your heels. You should feel a stretch through the tendons in the top of your foot. Other considerations are toenail health, shoe fitting and not giving your feet long enough to recover between runs.