The simple idea
Bilirubin comes from haem breakdown. First it is unconjugated, travels bound to albumin and reaches the liver. The liver takes it up, conjugates it using UGT1A1, and sends it into bile. Gut bacteria then convert it into pigments that colour stool.