Technically speaking, "gender" refers to the set of distinctive features of entities regarded as "male" or "female", including differences in genetics, physical structure, instinctive and learned behaviors, and (for humans, at least) cultural concepts associated with the other differences.
Sex, on the other hand,refers specifically to the genetic and physical component, particularly the configuration of the reproductive organs and the physical characteristics influenced by the sex hormones.
In an academic context, the term "gender" usually refers implicitly to whatever set of differences is most contextually relevant; most frequently this is the behavioral or cultural aspects, as otherwise the more specific term "sex" would be used. Note that the actual title of the article (but not the HN post) uses the narrower term.
In colloquial use the term gender tends to be used indiscriminately, largely due to a taboo over the term for physical differences also being used to refer to the act of sexual reproduction.