I never knew what a hard g and a study g was. Now I do. The rules are crazy.
Hard if it precedes a, o or u and if the word ends in g.
Soft if it precedes i, e or y. Add silent e if g is at the end and you want a soft g sound.
How in the hell did English manage to have a clear rule about anything?