Emerging evidence points to a strong association between the gut microbiota and the risk, development and progression of gastrointestinal cancers such as colorectal cancer (CRC) and hepatocellular carcinoma (HCC). Bile acids, produced in the liver, are metabolized by enzymes derived from intestinal bacteria and are critically important for maintaining a healthy gut microbiota, balanced lipid and carbohydrate metabolism, insulin sensitivity and innate immunity. Given the complexity of bile acid signalling and the direct biochemical interactions between the gut microbiota and the host, a systems biology perspective is required to understand the liver-bile acid-microbiota axis and its role in gastrointestinal carcinogenesis to reverse the microbiota-mediated alterations in bile acid metabolism that occur in disease states. An examination of recent research progress in this area is urgently needed. In this Review, we discuss the mechanistic links between bile acids and gastrointestinal carcinogenesis in CRC and HCC, which involve two major bile acid-sensing receptors, farnesoid X receptor (FXR) and G protein-coupled bile acid receptor 1 (TGR5). We also highlight the strategies and cutting-edge technologies to target gut-microbiota-dependent alterations in bile acid metabolism in the context of cancer therapy.