 Hartley was born in 1825 at Heworth, Gateshead, County Durham.He was educated at Bishop Auckland then Leeds.Like most engineers of his generation he was engaged in railway work in the early part of his career, being employed by the Scottish Central Railway.