I think following RankMath reference will be helped you.
Setting Canonical URLs in Rank Math >> Rank Math