For any square-free polynomial D over a finite field of characteristic at least 5, we present an algorithm for generating all cubic function fields of discriminant D. We also provide a count of all these fields according to their splitting at infinity. When D′ = D/(-3) has even degree and a leading coefficient that is a square, i.e. D′ is the discriminant of a real quadratic function field, this method makes use of the infrastructures of this field. This infrastructure method was first proposed by Shanks for cubic number fields in an unpublished manuscript from the late 1980s. While the mathematical ingredients of our construction are largely classical, our algorithm has the major computational advantage of finding very small minimal polynomials for the fields in question.