"The custom dates back to the Tang Dynasty, whose founder Emperor Tang Taizong honoured two of his most loyal generals - Qin Shubao and Yuchi Jingde - by having their painted portraits hung on his front door. Ordinary families soon adopted the imperial custom, putting woodblock prints of the ever-vigilant generals on their front gates in the hope of attracting good luck and fending off evil spirits. The Door God business soon spread throughout China, adding other folklore heroes and mythological figures to the repertoire."
The door gods usually come in pairs, facing each other; it is considered bad luck to place the figures back-to-back. There are several different forms of door gods. The most frequently used are Qin Shubao and Yuchi Jingde . The poster depicting Wei Zheng or Zhong Kui are used on single doors.
Origins of Door Gods
''Qin Qiong and Yuchi Jingde'' - Qin Qiong has pale skin and usually carries swords; Yuchi Jingde has dark skin and usually carries batons.
Qin and Yuchi , in a Tang dynasty lengend, were told by the emperor to guard the door because of a ghost harassing him, thus resulting in sleepless nights. When Qin and Yuchi were called, they guarded the emperor's door. Thus, the emperor had a blissful sleep. The next day, the emperor, not wanting to trouble his two generals, called on men to hang portraits of the two men either side of his door.
Other door gods
''Shentou and Yulei'' carry a battle axe and a , respectively. Shentou and Yulei were immortals who were ordered by the Jade Emperor to guard peach trees which demons were gnawing at. The people of China thus respected the two immortals for their ability to ward off demons.
''Zhong kui'' - strictly speaking not a Door God but a mythical ; nonetheless his image is often displayed as the "backdoor general".
The practice of placing door god figures is fading as of late, after a brief revival in the 1980s.
In the novel ''Journey to the West'' a fictional account of Li Shimin's invention of the Door god is mentioned.