Sam Imrie was convicted of two charges under separate Terrorism Acts and six other charges following a trial at the High Court in Edinburgh in October.
He posted statements online suggesting he was going to live-stream footage of “an incident” and posted footage pretending he had set fire to an Islamic center.
The 24-year-old from Glenrothes, Fife, also posted statements on social media platform Telegram and on Facebook that glorified acts by convicted terrorists Anders Breivik Brenton Tarrant and others.
Imrie, who had a photo of Hitler as his computer's screensaver, also made offensive comments about the Muslim and Jewish communities, and uttered racial remarks, which the charge stated he did with the intention of encouraging acts of terrorism.
Sentencing Imrie at the High Court in Glasgow on Thursday, Lord Mulholland said he was “spreading hate” and told him to use his time in jail to “remove hatred from your heart”.
Between June 20 and July 4, 2019, Imrie also had information of a kind “likely to be useful” to someone preparing an act of terrorism, namely copies of The Great Replacement by Tarrant, who killed 51 people at two mosques in New Zealand in 2019, and a manifesto by Breivik, who killed 77 people in two separate attacks in Norway in 2011.
He was also convicted of possessing extreme pornography, including indecent images of children and an image involving a human corpse, and of setting fires and of driving under the influence of drink or drugs.
Lord Mulholland said that Imrie revered white supremacists and referred to terrorists as heroes, lauding their kill counts of innocent people.
He added: “You were spreading hate and encouraging others to take terrorist action.
“Your conduct was despicable. You have no understanding or self awareness of the hate you sought to spread.
“Walk around any city, town or village and you will quickly find memorials to people of this country who gave their lives defending the freedoms you enjoy.”
He said the actions of mass murderers such as Breivik and Tarrant are to be “reviled”.
The judge also placed Imrie on the sex offenders register for 10 years and imposed a five-year serious crime prevention order which will start on the day of his release.
Imrie will also be subject to terrorism notification requirements for 15 years.
During the trial, the court heard that Imrie posted on far-right websites from his bedroom.
He became fascinated by the Nazis, making his computer password a violent racial slur and decorating his bedroom wardrobe with swastikas.
The court heard that his mother, Joyce Imrie, had described her son as a “loner” and a “recluse”.
In her statement to police on the day after her son’s arrest, Ms Imrie said: “I would describe him as a loner who very rarely leaves his room. He has no friends, no visitors to the house, no girlfriend that I’m aware of.”
Jim Keegan QC, representing Imrie, said that the 24-year-old had showed a “substantial lack of maturity”.
“Your Lordship has heard the accused giving evidence and his own acknowledgement that his behavior was inappropriate,” he said.
“What is clear from this case is that Sam Imrie was influenced online by the actions of others across the world and, by stating his own intentions, posed a significant threat to wider society,” said Detective Chief Superintendent Stuart Houston, head of Police Scotland’s Organized Crime and Counter Terrorism Unit.
“His actions clearly could have encouraged other people with similar beliefs and intentions to carry out acts with potentially catastrophic consequences, not just in Scotland, but anywhere in the world.
“This sentencing further highlights that there is no place for hate crime in Scotland and that it will not be tolerated in any form by Police Scotland.”