Chancellor Carol Christ is adhering to the First Amendment and the basic principles of academic freedom in ensuring that controversial speakers can appear on the UC Berkeley campus without endangering the safety of students, staff and faculty. Indeed, UC Berkeley has the chance to be a model for colleges and universities in showing that it is possible to protect freedom of speech in these polarized times.

The most basic principle of freedom of speech is that all ideas and views can be expressed. Never can government officials censor or punish the expression of any viewpoint, no matter how offensive. This is especially important on college campuses and particularly at UC Berkeley, where the Free Speech Movement of the 1960s was crucial in advancing the speech rights of students across the country.

Admittedly, the context is very different now than it was half a century ago. At that time, it was students demonstrating and campus officials trying to shut down their protests. Now, students’ protests are about speakers from off-campus, such as Ben Shapiro, Milo Yiannopoulos and Ann Coulter. The greatest concern is the threat of danger as groups like Antifa may be ready to engage in violence as they did last February, when their actions forced the campus to cancel Yiannopoulos’ speech. Furthermore, my sense is that speakers such as Yiannopoulos and Coulter are thrilled when they are kept from speaking by violence. It enables them to portray themselves as victims, vilify the left as intolerant and accuse campuses of being more concerned with indoctrination than the robust exchange of ideas.

In addition, student and faculty often differ in their attitudes towards free speech. According to a 2015 survey by the Pew Research Center, four in 10 college-age students believe that the government should be able to prevent people from publicly making statements that are offensive to minority groups. More students than ever support the exclusion of speakers similarly hateful messages. This impulse to suppress hateful speech stems from the laudable desire to make campuses inclusive for all. There is no doubt that hate speech causes great harm, especially among those who have been traditionally underrepresented in higher education.

But the law of the First Amendment is clear that speech cannot be punished or excluded on the grounds that it is hateful or even deeply offensive. In fact, as recently as June 2017, the Supreme Court unanimously noted that some say that “(the) Government has an interest in preventing speech expressing ideas that offend. And, as we have explained, that idea strikes at the heart of the First Amendment. Speech that demeans on the basis of race, ethnicity, gender, religion, age, disability, or any other similar ground is hateful; but the proudest boast of our free speech jurisprudence is that we protect the freedom to express ‘the thought that we hate.’ ”

Over 20 years ago, more than 350 colleges and universities adopted hate speech codes. These were well-intentioned and based on the recognition of the harms of hate speech. But every court to consider such hate speech codes declared them to be unconstitutional. The codes were inevitably far too vague in terms of what speech was permitted and what was prohibited. Even more importantly, the First Amendment promises that all ideas and views can be expressed, even hateful ones.

Free speech, of course, is not absolute. There are types of speech that are not protected by the First Amendment, such as child pornography, false advertising, incitement and true threats. But none of these provide a basis for excluding controversial speakers on our campus. Also, quite importantly, colleges and universities can have restrictions of time, place and manner on speech so long as such restrictions are neutral, serve an important purpose and open adequate alternative places for communication.

For example, campuses can regulate where and when speech occurs to prevent disruption to school activities — such as classroom instruction — and to protect public safety. The campus did an excellent job of safeguarding Ben Shapiro’s right to speak while ensuring safety. The cost was large; according to campus officials over $600,000 was spent on security. The planned “Free Speech Week” likely will cost more than that. These are dollars the campus can ill afford and inevitably will detract from the instructional mission of the school. Yet, Chancellor Carol Christ has made the right decision to spend this money. Failing to do so would require preventing the speakers from coming to campus, an action that would almost surely violate the First Amendment and cause UC Berkeley to be perceived as a censoring, hostile entity to the freedom of expression.

There might be a point at which it is impossible to protect public safety and allow speech to occur. Then, campus officials have no choice but to prevent the speech, as they must provide for the safety of students, staff and faculty. But canceling a speaker should be truly a last resort and never be based on the viewpoint expressed.

While we certainly can and should have discussions about the desirability of the First Amendment in this area, the law is clear that the campus cannot exclude speakers because the speakers are hateful or offensive. I also think that the Supreme Court has gotten it right in this area. The only way that my speech will be protected tomorrow is to safeguard the speech of others today, even if I detest what they are saying. After all, we don’t need freedom of speech for the messages we like; we would let them occur any way. Freedom of speech is all about protecting the expression we hate.

Erwin Chemerinsky is the dean of the UC Berkeley School of Law and the co-author of “Free Speech on Campus” with Howard Gillman.