We can find the first time Castellar was mentioned in the conservational act of the cathedral of Urgell, in the year 839, then as ‘Kastellare’.
Very probably the first building of Castellar had been the church of Santa Maria, building which had been replaced in the eleventh century by a Romanesque building which is partially preserved until nowadays.
Close to the church had been the castle, ‘castell’ that is indicated in the village’s name; You can still find some remains. People started housing and founding the later village by settling around the church. The castle inicially was sitouated outside the village.
Our town remained integrated in the domains of the counts of Cerdanya in the ninth century, together with other parts of the Vall de Lillet Valley, which would achieve its maximum territorial expansion under Oliva Cabreta, owner of the counties from 966 to 988. It was not until the thirteenth century that the area got part of the domains (vegueria or sotsvegueria) of Berga.
On the other hand, from the twelfth century on, Castellar de n’Hug belonged to the Mataplana domains, who in 1350 gained the barony category and from then on centered his power at his castle, located in the neighboring village of Gombrèn (Ripollès).
The Mataplana favored and encouraged the population of Castellar on several occasions. Most remarkable was the letter of franchises granted by Ramon Urtx, sir of Mataplana, on August 18, 1292, to all people who wanted to settle down in the village. This paper, a real town charter, allowed the inhabitants of Castellar to be free of census francs and services (except 12 annual dineros for houses and gardens) and free from the aforementioned misuse; gave them the freedom to work and crop (except the tithe, the firstborn and the eighth of the fruits of the earth) and freedom of movement within a year. Also they were freed of duty of surveillance of the castle in peacetime. Finally, they were given guarantees in judicial proceedings, which should be held in any event, in the same municipality of Castellar. These franchises were reconfirmed 1345 by Ramon Roger, Count of Pallars and lord of Mataplana.
The barony passed from Mataplana barony to lord Pere Galceran Pinos II as a result of the purchase in 1373, and was sold again three years later. Castellar de n'Hug finally remained within the possessions of the lords Mataplana Pinos, who were his successors. The first of these, Galceran de Pinos Bernat, 1383 swore to maintain and preserve the privileges of the inhabitants of Castellar.
In the nineteenth century, Castellar de n'Hug was affected by the Carlist wars, especially the third Carlist war, in whose battle close to the village the troops commanded by General Savalls were defeated by General Lopez Dominguez Alfonsi.
In the early twentieth century, families living in Castellar de n'Hug lived as high mountain villagers. They did any activities they could in order to survive: livestock and smuggling basically. The strategic position of Castellar had always had certain logistical implications both in peacetime and especially in wartime and post-war. The village and his habitants where witnesses of the dramatic happenings at the border in times of war. Castellar de n’Hug became a passage area of refugees and fugitives who brought along them all the amount of violence war had caused to them.
In 1860 the village had have 1005 inhabitants. The 1900 census stated 570 inhabitants and 1920 population had increased to 700 inhabitants, this rising of population was probably due to the installation of the Asland Factory. The village has currently about 150 registered inhabitants, of whom about 90 are year-long residents.
1904 General Asphalt Company Portland founded on Clot del Moro site the first Portland cement plant of the Spanish state. Its owner, Eusebi Guell assigned Rafael Guastavino (1842-1908) the design of the factory, which is still worth a visit because of its exceptional architectonical structuring.
The building, often described as a ‘waterfall factory’ is one of the great examples of industrial architecture in Catalonia. After that, homes of engineers and managers, the owner’s villa and a small church were built, all of them following that innovating style. The villa is a beautiful building of considerable interest, attributed to Antoni Gaudí and the modernist architect Ignasi Oms i Ponsa, whilst the chapel dedicated to Sant Jaume is a small Neo-Romanesque jewel designed by the engineer P. Palomar. Altl of them make the Clot del Moro site to be considered a unique industrial colony of great architectural value.
The factory closed in 1975 and later, but in 2002 the Museum Asland Cement was re-opened, as a part of the network of the National Museum of Science and Technology of Catalonia.
The Clot del Moro site had, from the year 1924 and until the closing of the cement factory, a small narrow gauge railway linking the factory to the Guardiola del Berguedà train station. It currently works as a tourism attration, the ‘Cement Train’.
Castellar de n'Hug has become a tourism reference in Catalonia during the last 30 years.
Back in 1984, when nobody in the Berguedà County even talked about of tourism nor trusted in its potential, villagers of Castellar de n’Hug decided to preserve folk architecture showing great respect for the use of local materials (stone, wood, tiles). That was one reason it was qualified one of the most beautiful villages of the whole Spanish state by the Ministry of Tourism. Definitely a deserved recognition of the efforts done by inhabitants and the City Council.