A small town in Midlothian, Bonnyrigg is located 6 miles (10 km) southeast of Edinburgh in the parishes of Cockpen and Lasswade. Bonnyrigg was a mining village until the 1920s. A carpet factory relocated here from Lasswade in the 1870s and operated until 1974. It was demolished in 1994, to be replaced by a supermarket. The village centre mostly dates from the 19th Century though buildings at the main crossroads were built in the 1960s. In 1929 Bonnyrigg united with Lasswade and has continued to grow through the construction of public housing at Waverley, Sherwood and Poltonhall and, more recently, private housing at Hopefield and Burnbrae. The combined settlement is twinned with Saint-Cyr-l'École, a commune in the west of Paris (France).
The Lasswade Centre opened on Eskdale Drive in 2013 and combines Lasswade High School, a library, sports centre and swimming pool on one site. There are four primary schools; namely Bonnyrigg Primary School (rebuilt 2009), Hawthornden Primary School (1969), St. Mary's Roman Catholic Primary School and Burnbrae Primary School (2012). Bonnyrigg Health Centre is located on the High Street. Bonnyrigg gained a railway station on the Peebles Line in 1855 and a second at Broomieknowe, to the north next to Lasswade, on the Esk Valley branch in 1868. The former closed in 1965, the latter in 1951. Bonnyrigg is now served by Lothian Buses, with direct services into the centre of Edinburgh. The Bonnyrigg Distributor Road (B6392) opened in sections from 1998 to relieve congestion in the town centre by connecting the A7 to the northeast with Rosewell Road (A6094) in the southwest.
In nearby Polton are found buildings from the 18th and 19th centuries including De Quincey Cottage (home of the writer Thomas De Quincey, 1840-59), Mavisbank House (1797) and Blairesk Hall (c.1818) while, to the southwest of Bonnyrigg, is Midfield House (18th-century, reconstructed 1914).
Prime Minister William Gladstone (1809-98) spoke here on 1st April 1880 as part of his Second Midlothian Campaign. Landscape painter William McTaggart died here in 1910, while fashion photographer Albert Watson (b.1942) was educated in Bonnyrigg at Lasswade High School and Judo champion Graeme Randall (b.1975) lives here.