וְנָתַתִּ֤י אֶת־עָֽרֵיכֶם֙ חָרְבָּ֔ה וַהֲשִׁמּוֹתִ֖י אֶת־מִקְדְּשֵׁיכֶ֑ם וְלֹ֣א אָרִ֔יחַ בְּרֵ֖יחַ נִיחֹֽחֲכֶֽם׃
Então a terra gozará os seus shabatot durante todos os dias da sua desolação, enquanto vós estiverdes na terra dos vossos inimigos; então a terra descansará, e gozará os seus shabatot.
Mishneh Torah, Prayer and the Priestly Blessing
Synagogues and houses of study that are in ruins retain their sacred character, as it is said, "And I will desolate your sanctuaries" (Leviticus 26:31)—even when desolate they still retain their sacred character. The same respect must be shown them when they are in ruins as when they were sound and in use. The only difference is in regard to sweeping and laying the dust. Synagogues in ruins are not swept nor sprinkled to lay the dust. If grass has sprung up in them, the blades are plucked and left there, so that the people may be stirred to rebuild the ruined edifices.
Arukh HaShulchan
Synagogues and study halls have great holiness since we pray in them and learn in them Torah. These locations have a reflection of the sanctity of the Temple. Our wise ones of blessed memory said, "And these will be small Temples" (Megilah 29a)-these are the Synagogues and study halls. And this that is written, "O Lord, You have been our dwelling place throughout all generations"(Psalms 90:1)- these are the Synagogues and study halls. Even in the time of the destruction [of the Temple], they still have sanctity as it is written, "and I will desolate your sanctuaries" (Lev. 26:31)-"They are still sanctuaries even when they are desolate" (Megilah 28a). Therefore, Synagogues and study halls are not treated with lightheartedness, for example, with games, humor and small talk. The Arizal (R' Issac Luria) was very careful to only speak words of prayer in the Synagogue. Even words of rebuke should not be spoken, least it lead to the discussion of mundane matters. (Magen Avraham Subsection 3).
Sefer HaChinukh
And [it] is practiced at the time of the [Temple] by the priests. And even today — not at the time of the [Temple] — they, may their memory be blessed, said (Megillah 28a) that we are warned not to enter the Temple [grounds]. And they expounded the matter, from that which is written (Leviticus 26:31) “and I will make your sanctuaries desolate,” and it did not state, “your sanctuaries will I make a desolation.” As it is implied that their holiness is [still] upon them, even when they are desolate. And since that is so, I should count this prohibition among the prohibitions that are observed today.