Google's John Mueller said you should absolutely not "use robots.txt to block indexing of URLs with parameters." He said if you do that then Google "cannot canonicalize the URLs, and you lose all of the value from links to those pages." Instead use rel-canonicals and link consistently throughout your site.
John said this on Twitter, here is an embed of the tweet:
Don't use robots.txt to block indexing of URLs with parameters. If you do that, we can't canonicalize the URLs, and you lose all of the value from links to those pages. Use rel-canonical, link cleanly internally, etc.
— 🍌 John 🍌 (@JohnMu) November 8, 2019
He then had a follow up about why it is so bad to block these URLs with robots.txt:
We wouldn't see the rel-canonical if it's blocked by robots.txt, so I'd pick either one or the other. If you do use robots.txt, we'll treat them like other robotted pages (and we won't know what's on the page, so we might index the URL without content).
— 🍌 John 🍌 (@JohnMu) November 8, 2019
So be careful about this and double check all of these things on your web sites.
Forum discussion at Twitter.