Yang Xuanyan served as a census official at Shu Prefecture (in modern Chengdu, Sichuan), and his family went there with him. He appeared to have had no sons, but had four daughters who were known to history — Yang Yuhuan and three older sisters. Yang Xuanyan died when Yang Yuhuan was still young, so the latter was raised by her uncle Yang Xuanjiao who was a low-ranking official at Henan Municipality
Yang Wang was a key official during the reign of Emperor Yang of Sui, and, after the fall of the Sui Dynasty, served one of the contenders to succeed Sui. Yang Wang was then killed by Tang forces in 621. Yang Wang was from Huayin, but his clan subsequently relocated to Yongle
An Lushan asked Lady Yang, who had no children, to become her adopted son. An Lushan finally launched his rebellion in the early winter of 755. He conquered much of northern China in half a year. On 14 July 756, the emperor fled the capital, arriving next day at a postal station named Mawei. There, mutinous soldiers began killing the once powerful relatives of Lady Yang and insisted that Guifei herself must be executed. The emperor was forced to consent to her hanging. Soon after, the Crown Prince declared himself emperor.
In 733, sixteen year-old Yang Yuhuan married the son of Emperor Xuanzong and Consort Wu, Li Mao the Prince of Shou. She thus carried the title of Princess of Shou. After Consort Wu died in 737, Emperor Xuanzong was greatly saddened by the death of his then-favorite concubine. Some time after that however Princess Yang somehow came into Xuanzong's favor and the emperor decided to take her as his consort.
In late 737, Xuanzong's favourite consort Wu died, after court intrigues that led to the execution of three of Xuanzong's sons, including the Crown Prince. Xuanzong fell in love with Lady Yang. After a fig-leaf legitimization of the union, the former daughter-in-law became the inseparable newfound love of the emperor. Since Princess Yang was already the wife of his son, Emperor Xuanzong stealthily arranged her to become a Taoist nun with the tonsured name Taizhen in order to prevent criticisms that would affect his plan of making her his concubine.