This question already has an answer here:
If a French citizen currently located in mainland China with a Chinese L (tourist) visa goes to Hong Kong for a short period (somewhere between a few hours to a few weeks) and comes back to mainland China, does that count as a new entry on a Chinese L (tourist) visa?
The question Would China to Taiwan and back again count as another entry into China? only addresses the case of Taiwan, which might differ from Hong Kong, since the latter is a special administrative regions (SAR). For example, Wikipedia gives some interesting differences between Taiwan and the SARs (= currently Hong Kong and Macau) in terms of entry procedures.