In China gods (menshen) were often painted on either side of a doorway to guard against evil demons or ghosts. The two gods in syncretistic Chinese folk religion who guard the double doorway of a domestic dwelling or public building. The Men-shen, literally "gods of the doorway", are believed to have been two generals from the Tang Dynasty, namely Qin Shu-bao and Hu Jing-de. They have been venerated since the 13th or 14th century. The back door is guarded by the less popular but still powerful Wei Ch'eng.The Chinese deity who guards the back door of domestic dwellings and public buildings. They are all former minister of emperor Tang Tai-zong. They are shown equipped with bows and arrows and magical symbols with which they avert evil spirits. According to legend, they also defended the 6th Tang emperor against attacking demons while he was asleep. The Men-shen appear as protectors in many folktales.The deities are portrayed as two men with terrifying facial expressions, in military uniform and/or armor and armed with a rapier or halberd. Affixed to their shoulders are tiny banners to signify their rank. The protective diety of the back door, Wei Cheng, is often included in the Men Shen thus making them a trio.Yuchi Jingde, also known as Wei Chigong, was one of the most celebrated military figures of the early Tang Dynasty. He and another great Chinese military general of the same era, Qin Shubao, adorn the doors and gates of temples, homes, and businesses in China and Chinese communities as Door Gods.In history, General Yuchi used his superb martial arts to save the life of the 2nd Tang emperor, Li Shimin, also known as Emperor Tang Taizong, both before and after he became emperor. During his involvement in the pivotal Xuanwu Gate Incident, General Yuchi helped Li Shimin defeat the forces of rival princes Li Yuanji and Li Jiancheng. After the defeat, he suggested that Li Shimin release Li Jiancheng’s men rather than execute them. His suggestion quickly eased the internal clash in the Tang Empire, and many talented people were retained.
Later, he requested that the current reigning Tang emperor, Emperor Gaozu, order all armies to fall under Li Shimin’s command, which stabilized the Tang Dynasty both internally and externally. Yuchi’s actions allowed Li Shimin to later become the Tang Dynasty emperor.
Yuchi Jingde was intelligent and farsighted. He had a simple and honest nature. He was always faithful to Li Shimin, and was willing to sacrifice his life for him without hesitation. After Tang Taizong hung portraits of Yuchi Jingde and Qin Shubao on his front doors, ordinary people took up this custom to attract good luck and fend off evil spirits. The custom continues to this day.