According to Qiu Zhu, Shu Xiang was written by Du Fu in the spring of the first year of Shangyuan (760). In December of the second year of Gan Yuan, Tang Suzong (759), Du Fu ended his four-year exile in Qin Zhou and Tonggu (now Chengxian County, Gansu Province) and, with the support of his friends, settled by Huanhua River in Chengdu. Chengdu used to be the capital of Shu and Han, and there is Zhuge Liang Temple in the northwest of the city, which is called Wuhou Temple.
In the spring of the first year of Shangyuan (760), Tang Suzong visited Zhuge Wuhou Temple and wrote this touching poem.