THEY were the last wishes of tens of thousands of young men who left to fight in foreign lands one hundred years ago and never returned.

The poignant wills and final testimonies of 26,000 First World War soldiers who were killed in action are to be made available online for the first time.

The documents, many of them drawn up on the eve of battles which would claim their writers' lives, have been released by the National Records of Scotland as part of commemorations of the centenary of the outbreak of the Great War.

They detail how many troops left all their worldy possessions to their mothers as they were too young to have started a family before they left for France and the Western Front.

Others have multiple entries after soldiers updated their wills following battles such as Ypres, Verdun and the Somme they did not expect to survive.

The records are drawn from all the Scottish infantry and cavalry regiments, as well as the Royal Artillery, Royal Army Medical Corps, Royal Army Service Corps, the Machine Gun Corps and other units, and a few who served in the Royal Flying Corps and the RAF.

Almost all the wills were written by soldiers below officer rank, but some wills for commissioned officers are also included.

Included are the wills of ancestors of famous Scots such as, John Feeley, the great-great-grandfather of the Paisley musician Paolo Nutini, and Andrew Cox, the uncle of Hollywood actor Brian Cox.

Private Feeley served in the Argyll and Sutherland Highlanders and died of wounds sustained during the Battle of Arras on April 23, 1917.

Feeley left all of his property and effects to his wife, Annie, who lived until 1964.

Private Cox, a rope-worker before the war, served with the Highland Light Infantry and was killed in the Battle of Neuve Chapelle, aged 22. His body was never identified.

Like many unmarried soldiers, Andrew Cox left all of his possessions to his mother, Elizabeth.

In addition to the wills from the Great War, there are almost 5000 from Scots soldiers serving in all theatres during the Second World War, several hundred from the Boer War and Korean War, and wills from other conflicts between 1857 and 1964.

Fiona Hyslop, Cabinet Secretary for Culture and External Affairs in the Scottish Government, said: "These small but powerful documents are a testament to the sacrifice in wartime made by thousands of Scots, not only the soldiers themselves, but also their families and loved ones."

Tim Ellis, Registrar General and Keeper of the Records of Scotland, said: "We are privileged to be marking the centenary of the start of the First World War by making these remarkable records available.

"They give us a unique insight into the service of Scottish soldiers during the First and Second World Wars, but also in other conflicts before and since."

Annelies van den Belt, the CEO of DC Thomson Family History, who enable the ScotlandsPeople website on behalf of the National Records of Scotland, said: "We're very pleased to add this new set of records to the ScotlandsPeople site. These fascinating documents make for poignant reading and we're sure that anyone who views the wills will feel a strong emotional connection to those who lost their lives in these conflicts."

A total of 147,609 Scots lost their lives in the four-year-long conflict from 1914 to 1918, a fifth of Britain's war dead. Twice as many Scots died per head of population than was the case south of the border.

The Soldiers' Wills are available at www.ScotlandsPeople.gov.uk, at the ScotlandsPeople Centre in Edinburgh, and at local family history centres in Glasgow, Kilmarnock, Hawick and Inverness.