Spoiler-ish and spoiler ahead
No, they really did not know they were both Tarans, even upon deathbed they did not know and Hugo did not tell them. They just coincidentally fell true in love and bore boi Damian. (I feel both happy and sad for them like )
For a girl to be born, the woman must eat/drink mugworth(was it this herb? not so sure anymore since it has been a long time since I read the novel) continuously since the start of menstruation and must not engage in any sexual intercourse with any until they have with a Taran. I remember they also have to drink the blood of the father to really guarantee that the semen(?) would develop but
SPOILER AHEAD ..
the Doctor in the story secretly made Lucia drink his secret medicine thru her doctor(who he was taking advantage of cuz she likes him) so she got pregnant with our spoiled-loved-by-all girl haha

oaky wait a sec, i'm a lil confused... i thought that children in the taran house could only be conceived two ways: for girls, to be conceived, the mother must consume that herb for at least a year? and then they can have a girl. to conceive a boy, i thought they could only be conceived between two tartan siblings?? so how did the heir come about???