Issue with Canonical URLs When Linking Blog Posts to Existing Discourse Topics

I’m encountering an issue when using the WP Discourse plugin, specifically in cases where I link a new blog post to an existing forum topic instead of creating a new topic.

The Problem:

When I publish a WordPress blog post and link it to an existing Discourse topic, the canonical URL for that topic remains set to the forum’s URL, not the blog post URL. This is different from when I use the “create a new topic” option for the blog post — in those cases, the canonical URL is always set to the blog URL.

Why This Matters:

In some cases, I already have a relevant discussion on the forum before I write a blog post on that topic. It makes sense to link the new blog post to the existing discussion rather than create a new topic. However, when I do this, the canonical URL points to the Discourse topic URL instead of the blog post URL.

What I Need:

I’d like a way to link a blog post to an existing Discourse topic while setting the canonical URL to the blog post URL, ensuring proper SEO attribution for the blog content.

Temporary Workaround:

I’ve done the following, although probably not ideal:

  1. Unlink affected blog post from the existing forum topic.
  2. Publish the blog post with create a new topicoption for WP-Discourse.
  3. Manually bulk-move all comments from the old topic to the new one.
  4. Set up a 301 redirect from the old forum topic URL to the blog post URL.

This results in the forum topic (comments) page pointing to the Blog post (which in all cases existed long before installing Discourse and wp-discorse) as the canonical URL. While the old forum post is also 301’d to the blog post URL as well.

This process works, but is time-consuming/not ideal.

Question:

Is there a way to configure the WP Discourse plugin or a workaround that allows the canonical URL to point to the blog post even when linking to an existing forum topic?