Dunfermline ( Scottish Gaelic : DÃ n PhÃ rlain ) is a town in Fife , Scotland . It sits on high ground three miles from the northern shore of the Firth of Forth , northwest of Edinburgh , and was an ancient capital of Scotland . Dunfermline ( Scottish Gaelic : DÃ n PhÃ rlain ) is a large town in Fife , Scotland , located on high ground 3 miles from the northern shore of the Firth of Forth .