Hoe kan ik een nieuw onderwerp aanmaken in Discourse via een link of de persoon ernaar verwijzen als het bestaat

AI-generated summary

jcayzac wants to create a “Discuss” link in a newsletter that either opens a new topic or directs users to an existing one in Discourse, depending on whether the topic already exists. They tried using the /new-topic?title=<url> method but found it creates duplicate topics. osioke clarifies that this behavior requires custom logic and suggests building a plugin or theme component. jcayzac asks whether adding a new parameter to the /new-topic route would be acceptable for a PR. Johani replies that modifying the /new-topic route to redirect to existing topics would be confusing and advises implementing the feature via a plugin instead.

We have a newsletter made of links to curated external resources. I’d like to add a Discuss link next to each item, which would point to a corresponding topic in our Discourse instance so that the newsletter audience can click to comment and engage others.

I tried using the trick mentioned at Compose a new pre-filled topic via URL, i.e. using a link with /new-topic?title=<url>, but this creates a new topic every time and this is not what I want.

I want the link to show the New Topic controller if the topic doesn’t exist yet, else take the visitor to the existing topic. Is there any way to achieve this with Discourse?

Thank you.

Sorry, I updated your topic title to be a bit more descriptive so other users can better find it via search as they look for support.

This will require some logic, and so you will definitely need to build something custom. Not sure if it is a theme component or plugin though, further research will be helpful to see which approach will be better.

I’m not familiar with the Discourse code base yet, but if I were to send a PR, would it be OK to add a new param to the existing /new-topic route, or would you prefer the feature to be isolated in a plugin?

Sorry, no.

/new-topic means a new topic.

If the new topic route results in a reply based on params, it would be confusing.

If that doesn’t work for your needs, you can modify the route in a plugin according to your needs.