The 2,700-year-old city was once the renowned banking capital of China, as important in the latter part of the Qing dynasty (1644 to 1912) as Wall Street is in the United States today.
In fact, Pingyao, which became a UNESCO World Heritage Site in 1997, still has some 4,000 traditional Chinese courtyard homes, dating as far back as the Ming dynasty (1368 to 1644).
An innovative program is now helping to restore these properties to their former glory.
What is a courtyard house?
Known as a "siheyuan," literally meaning a "quadrangle garden," each courtyard home comprises a courtyard surrounded by structures on all four sides.
A crumbling entry to a restored courtyard home.
"We can see how each courtyard home functioned from the way it is laid out," Li explains. "They actually give you a very clear idea of the history of the families and how they used to live."
In most cases, courtyard homes were divided into a main house, for the family; servants' quarters; and a yard, where horses were kept. Smaller courtyards were sometimes used as classrooms for the clan's children.
When Pingyao was China's financial capital, it was home to many wealthy businessmen with large families, Li explains. "They might have owned seven or eight courtyards in a row."
The size of each property served as a symbol for wealth and prosperity.
A lick of color and structural repairs made a huge difference to this courtyard home.
Preserving Pingyao
A decade ago, the Global Heritage Fund began working with the Pingyao municipality to preserve the ancient city. During this time, the fund's staff noted the large number of courtyard houses.
"There are thousands of them still in the historic city, but they are mostly under private ownership and are not designated protected monuments -- so that means the government didn't have any funding to preserve them," says Li, who joined the Global Heritage Fund in 2008.
Some of the homes were rentals, which meant they were "in bad shape," while others were occupied by low-income families, who simply didn't have the means to repair their dwellings.
The preservation project has been ongoing since 2012.
In 2012, the Global Heritage Fund helped the Planning Bureau set up a program to preserve the courtyard homes, which would see the local government provide a subsidy, and technical expertise, to homeowners.
Fixer-upper
The program has stringent rules regarding which courtyard homes are eligible for the program.
Firstly, homeowners have to provide proof of private ownership. Then the condition of their home is assessed.
"The oldest courtyard homes date back to the late Ming dynasty, but that doesn't mean every detail in the home is a relic from that period," Li says. "There would have been various additions and renovations made, because these houses were continuously occupied.
"If it has already been entirely renovated, or demolished and rebuilt, the house will not be considered."
After that, the order of renovation is prioritized according to how urgently each house needs it.
Owners are then granted a permit to restore their homes using construction firms that have been certified by the Planning Bureau, which also reviews their plans before any restoration begins. Finally, the work must be approved by a committee of local architects and historians before deemed complete.
Some owners turn their homes into guest houses, catering to Pingyao's popularity with visitors.
The government's subsidy of between $60 and $210 per square meter extends only to structural repairs and the restoration of the exteriors. Any shortfall must be paid by the homeowners, who are also responsible for beautifying the interiors.
According to the Planning Bureau, the restoration work costs, on average, $300 per square meter.
Who lives in courtyard homes?
Since the program began, 76 courtyard homes in Pingyao have been restored, and the government has contributed about $1.5 million in subsidies.
So who are the people looking to restore their homes -- and why?
Wang Xiaofeng, a teacher in her fifties who works in Beijing, renovated her courtyard home in 2015. It has been in her family for more than 40 years and boasts Ming and Qing details.
Having moved away as a child, Wang returns during the holidays, and it was on one of these trips that she decided to apply to the program, after a friend commented on the value of the property's ancient courtyard.
The house underwent structural repairs to its rooftop, walls, doors, windows and the western part of the courtyard. The Planning Bureau provided $10,230 and Wang put up $7,520.
"A lot of our traditional culture was lost in the past," she adds. "We should promote it and develop it."
Historic lodging
Other homeowners turn their renovated courtyard homes into profit-making ventures.
"Those who actually stay and run their own business -- like a bed and breakfast -- are the ones who take the most care of their houses," says Li.
Liu Xueru is one such homeowner. The 58-year-old Pingyao native owns his childhood 900-square-meter (9,688-square-feet) courtyard home with his two brothers. In 2009, he applied for restoration funding and created the 20-room Xiang Sheng Yuan Guest House.
Liu's late grandmother bought the home in the 1920s for 2,000 dayang -- a now-defunct currency that was used between the end of the Qing dynasty in 1912 and the establishment of the People's Republic of China in 1949.
"It's a building from the middle period of the Qing dynasty, (with) a larger courtyard and two smaller ones," says Liu.
Work began in 2015, with the rooftop being repaired and the interiors revived with a fresh coat of paint. The guest house opened the following year.
Liu received $9,920 in government subsidies and invested the same amount himself.
"I think these old courtyards need protection," Liu says. "The restoration is a continuous process."
Sign of the times
Restored traditional homes. Swanky converted guest houses. Does this signal a change in attitude towards historic preservation in China?
Li hopes so, and wants Pingyao's tourism strategy to pivot from merely entertaining visitors to teaching them about the city's unique past. She says: "We've been thinking about doing more cultural guide training ... so the historic value of the city can be better told."
"Today, more and more people understand the importance of preservation of cultural heritage," says Zhu Guangya, a professor at Southeast University's school of architecture.
But he notes there are difficulties in carrying it out.
"People have different opinions on how exactly to protect (historic buildings). Officially, China has accepted international principles and standards in heritage conservation -- but (in practice) not everyone knows about them."
And conservation can get sidelined in favor of things like property developers' financial interests, he adds.
In any case, Zhu agrees that Pingyao is a rare case of a "typical historic town from old China" having survived.
"China has a long history, the dynasties changed constantly, but its culture was never wiped out," he says.
"It's normal for old and new to work together. It's a type of cultural heritage ... and Pingyao is a textbook case of a historical town (preserved) for the Chinese today."
CNN's Nanlin Fang in Beijing contributed to this story.