Hansen was born at Larvik, in Vestfold, Norway. He was the son of Magistrate Frederik Christian Hansen (1799-1860) and Albine Elise Fougnerbakken (1801-1846). He earned his Cand.theol. degree in 1865. Subsequently, he became a teacher at the Norwegian Military Academy. From 1872, Hansen taught at Sagatun Folk High School in Hamar. In 1881 Hansen was a teacher at a private middle school in Stavanger. He was also editor of the Lillehammer newspaper Framgang. In 1890, he wrote Edvard Storm, digteren fra Vaage, a biography of the poet Edvard Storm. In 1896 he moved to Christiania (now Oslo) and was editor of Eidsvold. He was the chairman and founder of the regional centrist-conservative political party Centre in the 1890s."Partihistorie: Centrum". Norsk samfunnsvitenskapelig datatjeneste.
