What are minhagim based on?
Why are minhagim binding? In what capacity do we have to observe them? To answer these questions we are going to explore the halachic foundations upon which minhagim are based. There are two primary approaches to explain the obligation for minhagim. The first is based on a Gemara Nedarim 81b which states that one who violates a minhag is in a violation of a neder. The Ran (ibid.) explains that if a person practices a good practice with intention of continuing to keep that practice, rabbinically it is considered as though he took a vow and he is forbidden from breaking that vow. In order for the vow to be effective biblically he would have to enunciate it, however, rabbinically it is sufficient to have acted upon the intent to keep the practice.
The second approach to explain minhagim is based on a Gemara Pesachim 50b. The gemara relates a story in which the people of Bayshan took upon themselves a practice to refrain from traveling on Friday so as not to come to desecrate Shabbat. The next generation, however, found this practice too cumbersome and inhibited their ability to make a livelihood. Yet, when they asked Rabbi Yochanan if they could abolish this practice they were told that they should not disregard the practices of their parents citing a pasuk from Mishlei 1:8. The gemara implies that there is an inherent issue with breaking from communal practices and particularly apply to later generations. From the fact that the Gemara doesn't cite the violation of breaking a vow as the Gemara Nedarim does it seems that the Gemara Pesachim believes that there is another binding force of minhagim. Rav Hershel Schachter cites Rav Moshe Soloveitchik as having explained that the Rambam's opinion was that minhagim are binding because the act of breaking the minhag is an issue of separating from the community, which in it of itself is a problem.
Before offering practical applications, let us inquire whether each approach can accomodate the idea of personal as well as communal practices. If we suppose that minhagim are based on not abrogating communal customs, then seemingly personal practices would not be binding. However, if minhagim are based on vows, they certainly would apply to individuals; but would it also apply to a congregation? Rav Hershel Schachter in an article on yutorah.org explains that there is the concept of a communal vow and applies to everyone in the community. Furthermore, the communal vow is binding not only to the original community who accepted the practice but also to future generations. A proof for this concept is the Gemara Ketubot 111a, which states that the Jews took upon themselves three vows and theoretically they are binding upon Jews to this day. The concept could be explained by a similar concept we find regarding Korbanot. The Jewish community is considered a single unit that doesn't die because each successive generation fills the shoes of the previous one. Therefore, the Gemara Temurah 15b establishes that even though usually a person can not have a korban chatat brought on his behalf after he passes away, a congregation can do so because in reality the congregation lives on through their descendants.
Now that we have examined two approaches to minhagim, let us explore a few potential applications and see how each approach relates to that case. First, do minhagim apply to halachic scenarios? That is, what happens when minhag and halacha clashes? For example, there is a major discussion in the rishonim and achronim whether there is an obligation to wear Tefillin on Chol HaMoed. Let's suppose that I usually follow a certain Rabbi or sefer for my halachic questions and he says that I should wear Tefillin on Chol HaMoed, but my father's minhag is not to wear Tefillin, what should I do? According to the first approach, it is reasonable to assume that a community can only take upon themselves vows in gray areas of halacha. For example, the Gemara points out that a person may not vow to abrogate a mitzvah because that simply isn't up to his discretion. Similarly, the halachic question of wearing Tefillin on Chol HaMoed shouldn't be one decided upon by a community and its vow shouldn't be binding.However, according to the second approach it is possible that a community's practice is binding even in areas of halacha because however the practice was established, the individual should be restricted from breaking from the communal practices.
Does a person who moves communities need to continue his old practices or should he follow the customs of the place he entered? If one were to suppose that minhagim are like vows, it is logical that the vows should follow a person wherever he may be. However, if minhagim are a way of observing local customs, then upon moving one should adopt the local practices. In reality, everyone agrees that upon moving one should change his customs to follow the place where he plans on staying. It could be explained by supposing that the way communal vows work is that they only apply to a person while he is still part of that community.
Are minhagim binding if they were instituted in error? The Gemara Chullin 6b tells of a story in which Rabbi Yehuda HaNasi came to Beyt Shan and permitted the people not to take Trumot and Maaserot from their crops being that it was not part of Israel. However, the gemara asks how could Rabbi Yehuda HaNasi abrogate their minhag? To this the gemara answers that sometimes a later rabbi is given the opportunity to say something that no one before has said. Tosfot Pesachim 51a s.v. Iy though is bothered because this gemara seems to disregard the entire principle behind minhagim. Tosfot explains that minhagim are only binding when formulated with the correct knowledge of halacha and the minhag is just an added restriction or practice. However, if the community mistakenly thought something is forbidden when it is in reality permitted, that isn't a minhag at all. Seemingly, this idea fits nicely with the approach of communal vows because vows aren't binding when taken in error.
Lastly, is it possible to have a temporary minhag? If we assume that minhagim are based on vows, then certainly yes, because it is possible to stipulate that a certain vow should only apply for a certain amount of time. However, if we suppose that minhagim are based on not breaking from the practices of the everlasting Jewish community, then perhaps it is impossible for minhagim to be temporary just as biblical and rabbinic laws are permanent in nature. Yet, it seems that everyone can agree that minhagim could be instituted temporarily because minhagim are very much based on intent and if the community never accepted the practice with intent that it should last forever, reasonably it should be limited.
When minhagim clash with halacha
- A minhag is binding if it involves a stringency above the actual strict law. However, generally speaking, a minhag to follow one opinion on a matter that is a dispute in the Rishonim isn't a binding minhag.
- If a person has a practice in error, some say that it isn't binding and one doesn't require hatarat nedarim. However, others say that it is binding and in order for it to become permitted one would require hatarat nedarim. The halacha follows the first opinion. 
- A person who has a meritorious minhag, some say that it can never be broken, while others say that it can break that minhag with hatarat nedarim. The halacha follows the second opinion. 
- A communal minhag that is meritorious can only be broken if the entire community does hatarat nedarim. An individual can't abrogated the minhag if he does a personal hatarat nedarim.
- A minhag that was accepted by all Jews can't be broken by a hatarat nedarim.
- If one's parent had a meritorious practice, it is not binding upon the children unless they observe the practice one time, either in the life of their parent or after their death. 
- If a community has a practice, there is a dispute to what extent it applies to the next generation. One opinion holds that the minhag is not binding upon the next generation unless they have observed it one time. On the opposite end, some say the minhag is binding upon the children and it is impossible for them to do hatarat nedarim on that minhag because they weren't the ones who instituted it. In the middle are those who say that the minhag is binding upon the next generation but they can do hatarat nedarim just like the previous generation could.
- A minhag established by rabbis can't be abrogated.
- If a person moved from one community to another and plans on staying there, he should follow the minhagim of the place he is planning on staying. 
- If a person changes from one community to another, he should follow their minhagim but must be honest and follow all of their minhagim. Commonly when a man from one community marries a woman from another community, the woman takes upon herself the new minhagim of the community she is moving into. If the husband is a baal teshuva or a ger and doesn't have minhagim, he may accept the minhagim of his wife.
- If a woman changed her minhagim when she got married to adopt her husband's minhagim and now she is a widow or divorcee if she has children from her husband she should continue to follow the minhagim of her husband. However, if she doesn't have any children she should return to the minhagim of her father's house.
- Some say that a Sephardi who learns by Rabbis who are Ashkenazic doesn’t have to follow the minhagim of his Rabbis and can continue to follow the minhag of his parents. 
- Minhagim of Chanuka
- Source sheet for above essay on Minhagim
- How to undo a Minhag by Rabbi Gil Student
- Tur and Shulchan Aruch 214:1 cite the approach of the Ran. Birkei Yosef YD 214 also points out that it is only treated like a neder and is binding rabbinically. Thus, if there is a doubt if something is prohibited based on a minhag, one may be lenient.
- The Ramban (Mishpat HaCherem, cited by the Bet Yosef YD 214:2) describes minhagim as communal acceptances and doesn't use the language of vows.
- Nefesh HaRav (p. 235)
- Pirkei Avot 2:4. See Nefesh HaRav where he explains that separating from the community is a way of breaking from the tradition in which the Torah was meant to be kept. The Torah was given to Bnei Yisrael as a unit (see Rashi Shemot 19:2) and should be kept that way. A person who deviates from communal practices is in essence causing the Torah to be perverted.
- For further discussion of this topic, see a letter of the Rogachover (Safnat Paneach 143:2) regarding the vow that Yosef made his brothers take. Other proofs are the oath bnei yisrael took against the tribe of Binyamin by Pilegesh B'givah and the acceptance of the Torah, which is sometimes described as an oath.
- This position is endorsed by the Sdei Chemed (v. 4, n. 38) and Yabia Omer O.C. 2:23. Both express the idea that the institutors of the minhag may not have the ability to be a decider of halacha to arbitrate between the rishonim. In such a case, the minhag is not binding. According to this opinion, as opposed to issues of minhag, on issues of halacha a person should follow his personal Rebbe Muvhak like the Chazon Ish YD 150:1 writes.
- In fact, the Ohr Letzion (v. 2, p. 17-8 and v. 1, 5:7) advocates this approach with reservation. He explains that the community of Rabbi Yose HaGlali ate cheese and chicken together because the opinion of Rabbi Yose was that it was permitted even though the other Rabbis forbad it. Even after Rabbi Yose died, they followed his opinion, says the Or Letzion, because once they practice in accordance with his opinion before it was known to be a dispute, for that community it remains a permitted activity and do not need to consider the other opinion. One of his proofs is the Rambam (Shmitta VeYovel 10:6) who writes although he believes that the halacha does not follow the geonim in their count of the Shmitta cycle, because the practice is like the geonim, the practice should continue.
- Shulchan Aruch YD 214:2
- Shulchan Aruch YD 232:10. See Mishna Nedarim 25b.
- It is clear from chazal that one may stipulate a vow to apply to a certain time period. A simple proof is the Mishna Nedarim 57a. Additionally, Shulchan Aruch YD 214:1 implies that if one has a practice that one only plans on doing a couple of times and not forever, it isn't binding as an oath, yet to any question, one should stipulate so explicitly.
- The concept that minhagim can have a limited time-frame is shown in Shulchan Aruch YD 228:27.
- Sdei Chemed (v. 4, Maarechet Mem, Klal 37)
- Tosfot Pesachim 51a s.v. Iy and the Rosh (Pesachim 4:3) hold that a minhag that is based on an error isn't binding at all and may be abrogated without any hatarat nedarim. Their proof is the gemara Chullin 6b. The Ran (Pesachim 17a) and Rashba (responsa 3:236) hold that a minhag made in error is binding and can only be broken with hatarat nedarim. Each opinion differs in how they understand the Yerushalmi Pesachim 4:1 which states that a minhag made in error can be abrogated. The Rosh would understand it to mean that it can be abrogated without any formal process. The Ran, however, would explain the Yerushalmi as saying that it could only be broken with hatarat nedarim. Shulchan Aruch YD 214:1 quotes the Rosh as the primary opinion but also cites the Ran. The Rama follows the Rosh. Also, the Pri Chadash (Dinei Minhagei Issur #1) writes that the halacha is like the Rosh and brings proofs to that effect.
- Tosfot Pesachim 51a s.v. Iy and the Rosh (Pesachim 4:3) hold that a meritorious minhag is binding like a neder but can be broken with hatarat nedarim. However, the Ran (Pesachim 17a) and Rashba (responsa 3:236, cited by Bet Yosef YD 214:1) hold that minhagim can't be broken if it is meritorious. The two opinions differ in how they understand the Yerushalmi Pesachim 4:1 which says that a good minhag can't be abrogated. The Rosh understands it to mean that without hatarat nedarim it can't be broken. The Ran, however, understands the Yerushalmi more absolutely, a good minhag can not be broken. Another proof for the Ran is the Yerushalmi Nedarim 5:4 which forbad permitting a neder against gambling, even though theoretically some say there is no prohibition with gambling (see Sanhedrin 24b). Shulchan Aruch YD 214:1 rules like the Rosh. The Pri Chadash (Dinei Minhagei Issur #1) also rules like the Rosh but wonders why Shulchan Aruch YD 228:15 rules like the Rivash, who follows the Ran.
- Pri Chadash (Dinei Minhagei Issur #5)
- Pri Chadash (Dinei Minhagei Issur #6) citing Sh"t Maharshal 7
- Pri Chadash (Dinei Minhagei Issur #7) based on the Gemara Chullin 105a
- Zichron Yosef YD 14 cited by Pitchei Teshuva YD 214:5
- Maharshdam YD 40, Maharik 144
- Pri Chadash (Dinei Minhagei Issur #8)
- Radvaz 3:532
- Shulchan Aruch YD 214:2
- Tashbetz 3:179 explains that if a man marries a woman from another community with different minhagim certainly they should follow the man's minhagim. It couldn't be that a couple sitting at one table would have certain foods that are permitted to one and forbidden to another. Rav Hershel Schachter in a shiur on yutorah.org (Hilchos Pesach min 10-12) said that generally when a couple gets married and they each have different minhagim they should follow the man's minhagim. It is permitted to change one's old minhagim since one is permanently moving into a new community. However, if he doesn't have minhagim such as if he's a baal teshuva or ger they should follow the wife's minhagim. [The Sephardic Halachah Newsletter v. 7 p. 3] cites Igrot Moshe OC 1:158, Minchat Yitzchak 4:83, Halichot Shlomo 1:7, Rav Elyashiv in Ashrei Haish 3:59:2 who agree.
- Tashbetz 3:179 learns from the concept of the daughter of a Cohen who is considered to be a Yisrael for purposes of Trumah as long as she is married to a Cohen. Even after the husband dies or divorces her she is still considered a Yisrael as long as she has children. However, if she doesn't have children "she returns to her father's house" and is considered a daughter of a Cohen. The Tashbetz applies this system to a couple married where the man and woman come from different communities.
- Sh"t Or Letzion (vol 2 pg 17-18) writes that one should follow the minhag of one’s parents and not that of one’s rabbis.