Machiya

 are traditional wooden townhouses found throughout Japan and typified in the historical capital of Kyoto. (townhouses) and (farm dwellings) constitute the two categories of Japanese vernacular architecture known as (folk dwellings).
 originated as early as the Heian period and continued to develop through to the Edo period and even into the Meiji period. housed urban merchants and craftsmen, a class collectively referred to as (townspeople).
The word is written using two kanji: meaning "town", and meaning "house" () or "shop" () depending on the kanji used to express it.
 in Kyoto, sometimes called , formed the defining characteristic of downtown Kyoto architecture for centuries, representing the standard defining form of the throughout the country.
The typical Kyoto is a long wooden home with narrow street frontage, stretching deep into the city block and often containing one or more small courtyard gardens, known as . incorporate earthen walls and baked tile roofs, and are typically one, one and a half or two stories high, occasionally stretching to three stories. The front of the building traditionally served as the retail or shop space, known as (lit., "shop space"), typically having sliding or folding shutters that could open to display goods and wares.
Behind the shop space, the remainder of the main building would be divided into the (lit., "living room"), composed of divided rooms with raised timber floors and tatami mats coverings. would also feature a or , an unfloored earthen service space that contained the kitchen, also serving as the passage to the rear of the plot, where storehouses known as would be found. 
A above the kitchen would serve as a chimney, carrying smoke and heat away, and also serve as a skylight, bringing light into the kitchen. The plot's width was traditionally an index of wealth, and typical plots would be just to wide but deep, leading to the nickname , or "eel beds".
The largest residential room in a , located in the rear of the main building and looking out over the garden which separated the main house from the storehouse, was known as the , and doubled as a reception room for special guests or clients. The sliding doors which made up the walls in a , as in most traditional Japanese buildings, provided a great degree of versatility; doors could be opened and closed or removed entirely to alter the number, size, and shape of rooms to suit the needs of the moment. Typically, however, the remainder of the building might be arranged to create smaller rooms, including an entrance hall or foyer ("genkan" []), , and , both of which mean simply "central room".
One occasion when rooms would be altered significantly is during the Gion Matsuri, when families would display their family treasures, including (folding screen) paintings and other artworks and heirlooms in the . also provided space for costumes, decorations, portable shrines ("omikoshi" []), floats, and other things needed for the festival, as well as hosting spectators along the festival's parade route.
The design of a was also well-suited for the climate of Kyoto; with cold winters and often exceedingly-hot, humid summers, multiple layers of sliding doors ( and ) could be added or removed to moderate the temperature inside; closing all the screens in the winter would offer some protection from the cold, while opening them all in the summer offered some respite from the heat and humidity. 
 homes traditionally also made use of different types of screens which would be changed with the seasons; woven bamboo screens used in summer allowed air to flow through, but helped to block the sun. The open air garden courtyards likewise aided in air circulation and brought light into the house.
Design elements.
The front of a features wooden lattices, or , the styles of which were once indicative of the type of shop the held. Silk or thread shops, rice sellers, (geisha houses), and liquor stores, among others, each had their own distinctive style of latticework. The types or styles of latticework are still today known by names using shop types, such as (lit., "thread shop lattice") or (lit., "rice shop lattice). These lattices sometimes jut out from the front of the building, in which case they are known as . Normally unpainted, the of (geisha and communities) were frequently painted in , a vermillion or red ochre color.
The facade of the second story of a is generally not made of wood, but of earthwork, with a distinctive style of window known as (lit., "insect cage window").
The main entrance into a consists of two doors. The (lit., "big door") was generally used only to transport goods, or large objects, into the building, while the smaller , or "side door", was for normal, everyday use, i.e. for people to enter and exit.
 often contain small courtyard gardens.
Community.
 communities can be compared to the s of Beijing. Small neighborhoods made up of closely grouped homes organized on both sides of a narrow street, sometimes with small alleyways ("roji" []) in between the homes, help to create a strong sense of community. In addition, many areas were traditionally defined by a single craft or product. The neighborhood, for example, is famous for its textiles; sharing a craft contributed greatly to a sense of community among fellow textile merchants in this area.
Destruction.
, despite their status as part of Japan's cultural heritage, have undergone rapid decline in numbers in recent decades, with many being demolished in order to provide space for new buildings. Many reasons for this decline exist; are considered to be difficult and expensive to maintain, are subject to greater risk of damage from fires or earthquakes than modern buildings, and are considered old-fashioned and outdated by some. In a survey conducted in 2003, over 50% of residents noted that it is financially difficult to maintain a .
Between 1993 and 2003, over 13% of the in Kyoto were demolished. Roughly forty percent of those demolished were replaced with new modern houses, and another 40% were replaced with high-rise apartment buildings, parking lots, or modern-style commercial shops Of those remaining, over 80% have suffered significant losses to the traditional appearance of their facades. Roughly 20% of Kyoto's have been altered in a process called (lit., "signboard architecture"), retaining the basic shape of a , but their facades have been completely covered over in cement, which replaces the wooden lattices of the first story and windows and earthwork walls of the second story. Many of these have also lost their tile roofs, becoming more boxed-out in shape; many have also had aluminum or steel shutters installed, as are commonly seen in small urban shops around the world.
In response to the decline in numbers, however, some groups have formed with the express aim of restoring and protecting the found in Kyoto. One such institution, the Fund", was established in 2005 with the backing of a Tokyo-based benefactor. The group works alongside individual owners to restore their buildings and to have them designated as "Structures of Scenic Importance" ("keikan jūyō kenzōbutsu" []); under this designation, the structures are protected from demolition without the permission of the mayor of Kyoto, and a stipend is provided by the city government to the owners of the to help support the upkeep of the building. Many of these restored buildings serve, at least in part, as community centers.
, a company founded by art collector, author, and traditional culture advocate Alex Kerr in 2004 to save old , owns a number of which it restored, maintains, and rents to travelers. The company's main office, itself located in a , houses a traditional arts practice space, including a full-size Noh stage.
Examples.
There are many remaining in Kyoto. Many are private residences, while others operating as businesses, notably cafes, and a few are museums. The largest in Kyoto is in , the traditional (lit., "pleasure quarter") of Kyoto.