Here are some things I think about when writing hugs to try to make them fit with the characters and the current emotional tone of the story, as well as have anywhere near the same impact of hugs in visual mediums.
When? (Who?)
The frequency a character will hug is usually pretty dependent on the nature of the character. Are they emotionally or physically reticent to the point that a hug from them probably means the world is ending? Will they hug on special occasions (the college graduation or the 'we both just nearly died' depending on genre) Or are they more touchy-feely? Then there's more minutia, do they refrain from hugs because they just don't like them? Or because they don't want to cross others' boundaries? Were they raised in a household where spontaneous hugs were commonplace or where they could count them on one hand?
Why?
The "why" of a hug has a big impact on the energy of it and often how many details you write into it. Is it a happy hug? Sad? A complicated mix of emotions? Casual? This can also affect the "how" of the hug. If it's a "I thought you were dead!" hug it's unlikely to be a loose side-hug. If it's a "Oh, nice to see you :)" it's unlikely to be a strangling bear hug. Overall the emotions of both people involved should be your guide to writing it.
How?
First thing I consider is usually the initiator. Does one person initiate? Do both people equally initiate? Does someone open their arms and the other steps into the hug? Do they resist the hug? Do they melt into the hug? This typically links back into both the why of the hug, and who the characters are. I also try to think of the "motivation" of a hug which can be conscious or subconscious. Is the initiator hugging to provide comfort? Express gratitude? Reassure themself? Something else?
Arms! Placement is often influenced by height. Both arms over? Both arms under? One under/one over? Squeeze?
Hands! Actions: Clutching at clothes? Rubbing circles? Patting? Ruffling hair? Placement: Back of neck? Lower/mid/upper back? Hair/back of head? Wrap around to their side?
Tightness! Loose? Gentle? Tight? Suffocating? Are there injuries to be considerate of? Are they tired or energized? How conscientious are they of how tight they're holding?
Duration! Is it a quick hug then pull away? Does one awkwardly pull back after a few seconds? Do they both cling on for just a little too long? Does the initiator end the hug, does the receiver, or is it mutually done? Communicated by a loosening grip or back slap?
Head! Chin on the top of the head? Burying their face in the other person's shoulder/chest? Turning their head to the side? Looking up? Staring into the distance? Closing their eyes? Crying? Stoic? Smiling?
Stance/Big picture! Are they both standing? One standing one sitting? One lying down and the other crouched? Some sort of other awkward positioning? Do they rock side to side when they hug -- who is rocking? Does one pick up the other? Swing them around? Is it a run-into hug where they're both staggering/nearly falling with the impact? Is one standing stiffly with their arms sticking to the side? Are they relaxed? One leaning into the other, both leaning, neither?
Dynamism! Similar to big picture, but how much is the hug moving? Rocking side to side? moving hands/adjusting grip? Moving head? Staggering back? Standing as still as a statue for the whole duration? Are they talking during it? Quiet?
Alternate hug-ish stuff! One-armed hug, hugging an arm/leg, arm slung over the other's shoulder, hug for a practical purpose (stabilization, restraining, carrying, tackle), group hugs, unintentional proximity (trapped in enclosed space, tied up)
Hug Examples! Watch examples of hugs from shows, movies, etc and try to note the little details that can help feel more evocative, natural, or memorable. How did the body language of the actors convey how the characters were feeling? How did the hug feel to you?
(First 2 are from the Magnum PI reboot, next 4 Macgyver reboot, next 2 White Collar, last 2 Hercules: The Legendary Journeys. If you want to know a specific episode for any of them I will go and track it down for you)
Forgive the limited variety of shows, I only have so many images of people hugging on hand