The Bible story
Mary and Joseph on the Road to Bethlehem
Caesar Augustus ordered a census of the whole empire, so Joseph went from Nazareth to Bethlehem, the town of David, because he belonged to David’s family. Mary, who was expecting her baby, went with him.
So Joseph also went up from Nazareth in Galilee to Judea, to the city of David called Bethlehem, since he was from the house and line of David.
— Luke 2:4 (BSB)
Luke does not say how they traveled; the donkey is a much-loved tradition.
Read the whole story: Luke 2:1–5