Question: Can Nichum Aveilim be done on Yom Tov and Chol Hamoed?
Answer: As is common regarding the laws of aveilut, there is a gulf between the gemara’s principles and current practice, but we will try to make some peace between them.
The gemara is clear that one may do nichum aveilim not only on Chol Hamoed but even on Shabbat and Yom Tov. The gemara (Shabbat 12a) says that Beit Shammai and Beit Hillel disagreed if it is permitted on Shabbat, and the halacha follows Beit Hillel, who permit it. A baraita (Sukka 41b) describing a person going from place to place holding a lulav and etrog mentions one going to nichum aveilim. The gemara (Moed Katan 20a) even says that since people do nichum aveilim on a mo’ed (even though shiva does not begin until after the chag), the number of days of chag after the burial are subtracted from the number of days of nichum aveilim after the chag because of nichum on the chag. So, for example, if there were three days of chag before shiva began, only on the first four days of shiva are people expected to be menachem (see Shulchan Aruch, Yoreh Deah 399:2).
Several relatively recent Acharonim point out that the minhag in our times is not to do nichum aveilim on Shabbat and/or chag. The Aruch Hashulchan (Orach Chayim 287:3) and Kaf Hachayim (OC 287:4) say this in regard to Shabbat. Rav Moshe Feinstein (Igrot Moshe, YD II:172) reports that the same is true regarding Yom Tov and Chol Hamoed and suggests that this is the reason that we now assume that nichum aveilim is done during the entire period of shiva after chag even if the burial was during Chol Hamoed.
How did the change in practice come about? The following gemara (Shabbat 12b) may be most instructive: "Reluctantly, they permitted on Shabbat to console mourners and visit the sick." Rashi (ad loc.) explains that the problem with nichum is that it raises upsetting things, and the Rif (Shabbat 5b) says that the visitor may scream out too strongly for this festive day. (This helps explain the Shulchan Aruch’s (OC 287:1) ruling that we use a different formula for nichum on Shabbat than during the week, although the Mishna Berura (287:3) also cites an opinion that one can use the regular one.) The Magen Avraham (287:1) expresses displeasure with those who improperly take advantage of "free time" specifically on Shabbat to do such mitzvot that are preferably done during the week. The Nimukei Orach Chayim (287:1) says that things have improved in this matter since the gemara’s time, as people now are careful to be menachem avel specifically during the week. He also points out that the nichum should be done with the aveilim sitting low, which should not be done on Shabbat, as it is public mourning. This finds expression in halachic practice in that we stopped doing this non-ideal nichum totally. While he does not discuss chagim, much of the same logic applies to it as well.
The Shevet Halevi (IV:53) points out that the factors that the Nimukei Orach Chayim raises existed in the gemara’s time. The B’tzel Hachochma (II:44) cites many Rishonim who describe nichum on Shabbat as a normal thing to do, and therefore says that we should not reject it. He even mentions some positives about it (people have time, are dressed nicely).
The Gesher Hachayim (20:5:2) says that the minhag of Ashkenazim is to not do nichum on Shabbat or Yom Tov, but yes to do it on Chol Hamoed. As mentioned, more recent poskim (see Igrot Moshe, ibid.; Rav Auerbach, cited in Shemirat Shabbat K’hilchata 65:(181)) state that it is not practiced even on Chol Hamoed. Sephardic minhag (see Yalkut Yosef, Sova Semachot 26:2) is to sanction, even on Shabbat, to be menachem in the mourner’s house, when this is the only time he can do it. Ashkenazim do no more than mention one’s regrets and discuss feelings informally with the avel in shul. It seems that the Ashkenazic approach is that coming to an avel’s home is done only when he is accepting visitors as part of shiva (at the hours they set). At other times, only people who are very close would venture in.
279 - Avinu Malkeinu When Yom Kippur Falls Out on Shabbat
280 - Nichum Aveilim on Yom Tov and Chol Hamoed
281 - Maintaining a Possibly Grafted Tree