The origins of the present-day community in the Llynfi Valley date from the late 1820s when the area’s considerable coal and iron-ore resources were developed on an industrial scale for the first time. In 1828 a fifteen-mile horse-drawn railway was completed between a new harbour at Porthcawl and Garnlwyd in the Llynfi Valley. This was the Dyffryn Llynfi and Porthcawl Railway (DLPR); it was extended to the Coegnant district near the head of the valley in 1830.[4] The railway opened-up the district and prompted the formation of an iron company which began building a works on Maesteg Uchaf Farm, near the site of the present-day town centre, in 1826.
Source Wiki.