The sex of the baby should be kept secret until birth
When Kate was pregnant, she was not allowed to reveal the sex of the baby, neither was William allowed to do that, as father of the child. As that is not the role of the prince and the princess. The parents were obviously aware of her gender, but in the royal family, the surprise is kept until the end. No matter how much William and Kate may have wanted to make the announcement of the gender of their baby, they just weren’t allowed to do it. There is a whole process that has to happen before a gender revealing announcement can be made public.
The British royal family generally does not disclose the sex of the baby during pregnancy. Everything is kept in the strictest confidence before the birth of the child. The company likes to speculate about it and even to bet. The birth must be officially announced by a bulletin signed by the doctors which will be transported by car from the hospital to Buckingham Palace, where it will be displayed on an easel posted on the gates. There is a whole protocol in place when making this sort of a revelation, unlike in non-royal households, where the parents are most typically the ones to break the news to their family.