Jake Newsome, 21, took to the social networking site three days after Mrs Maguire was stabbed at Corpus Christi college in Leeds, on April 28.
Prosecutor Sandra White told Leeds Magistrates Court today: “This message was posted to the Facebook social network on May 1 from Mr Newsome’s phone.
“He wrote ‘Personally, I’m glad that teacher got stabbed up.”
“Four minutes later a comment was posted saying,’That’s not very nice’, to which the defendant replied, ‘I think it is’.”
After he posted the message, people began to leave comments in response and Newsome was arrested.
Newsome admitted posting the message but told polcie he “didn’t think they were offensive”, the court heard.
Ann Glen, for Newsome, said her client had no previous convictions and he had understood he would “reap the consequences realising that he had offended members of the public”.
Sentencing him after he admitted sending an offensive message at a previous hearing, District Judge David Kitson said: “You sent an offensive communication by an electronic device that followed the tragic death of Mrs Maguire who was killed some days previously.
“You’re entitled to express reasonable views, as are all of us. What none of us are entitled to do is abuse that freedom.
“What I find particularly offensive - that must have caused distress to all those who knew Mrs Maguire - were the derogatory remarks made saying that you were glad she had been killed... I can think of little more that can be upsetting or offensive.”
Mr Kitson added: “You clearly came from a troubled background. But this is so serious that nothing more than custodial sentence can suffice.”
Newsome, wearing a dark hoodie and blue jeans, looked shocked at the decision. As he was led away from court his friends sat sobbing in the public gallery. He will serve half of the six-week sentence.
Mrs Maguire, 61, died after she was attacked as she taught a Spanish lesson.
• A 15-year-old boy has appeared in court accused of murdering Mrs Maguire. He is remanded in custody and is due to go on trial later this year.