Hello, we apologize for the inconvenience you’re facing. Currently, Rank Math does not support displaying a custom canonical URL in the sitemap instead of the main URL. The canonical URL in the sitemap is automatically generated based on the settings and the canonical URL you’ve set for your posts or pages.
If you have any further questions or need assistance with anything else, please feel free to reach out to our support team directly from here: Rank Math Support, and we’re always here to help.
Sources:
Alternate Page with Proper Canonical Tag Status in Google Search Console » Rank Math
Bulk Editing Options in the Rank Math SEO Plugin
Setting Canonical URLs in Rank Math » Rank Math
How to Fix ‘Duplicate Without User-Selected Canonical’ Status in Google Search Console » Rank Math
Is there any way I can add variable in the post url in sitemap?
Hello,
Thank you for your query and we are so sorry about the trouble this must have caused.
Unfortunately, Rank Math can’t add the actual canonical URL to the sitemap.
If you wish to add further modification to your sitemap, I suggest checking our filter codes here: https://rankmath.com/kb/filters-hooks-api-developer/#sitemap
Hope that helps and please do not hesitate to let us know if you need my assistance with anything else.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.