I don't give kids hugs but I am big into high fives and hand shakes. If a kid wants to hug me, I'll let him/her do so and give a quick hug back/pat on the back and then move on. I do a lot of verbal encouragement. If a kid wants to hold my hand I'll let them, but it's never something I initiate. Most kids who will offer hugs or want to hold hands are in kindegarten, and at that age I think it is OK.
There was this one time when in a middle school, a girl who was really upset and who I knew well wanted a hug so I let her hug me and patted her on the back/gave a quick hug and moved away. I don't think that was inappropriate. Hugging girl middle school students is definitely something I do not do, this happened in one particular situation and I don't think any of the students or staff saw that as inappropriate. It was years ago so
I probably would have heard about it by now.
But yeah, you can't be too careful.