The most common solution in a divorce is to sell the house and split the profits. It’s common to split the profits 50/50, but that can change due to a myriad of reasons like a pre-nuptial agreement, one party wants to keep their retirement account in place, etc.
If one person wants to stay in the house, it’s possible to buy the other person out, as long as they can do it financially. First, both parties have to agree on a price, which is not a foregone conclusion. They can have it appraised but one party may feel the appraisal is too high (or too low). Then the party that’s remaining has to be able to put their hands on enough cash to buy the departing party out.
If the home has a mortgage, that complicates things greatly. I’m continually amazed at how many judges and divorce attorneys appear to have NO knowledge about how mortgages work. I’ve seen many final divorce papers where it’s ordered that the departing spouse signs a quit claim giving up all ownership rights and the remaining spouse is ordered to make the payment. But if the underlying loan isn’t refinanced, the departing spouse is likely still obligated on that loan. This can make it difficult for them to qualify for a new loan plus hurt their credit if the remaining spouse misses payments. I’ve also seen where the remaining spouse is ordered to refinance the house to get it out of both names. But no one recognized how hard it may be to refinance a home when you are going from a likely two-income household to one, and then you add in new monthly obligations of alimony and/or child support payments. In rare situations, the loan may be assumable.