thereby hangs a tale
That detail or incident reminds one of another story, as in So he went without supper, but thereby hangs a tale. This expression, embodying the pun on tail and tale, was used by Shakespeare in at least four of his plays and presumably was well known before that. [1500s]
Dictionary.com presents 366 FAQs, incorporating some of the frequently asked questions from the past with newer queries.