This documentation explains how to create a link that starts a new topic in Discourse with pre-filled information.
Required user level: All users
Sometimes, you may want to provide users with a link that initiates a new topic composer with certain fields pre-filled. This can be useful for various use cases including bug report templates, feature requests, or standardized posts.
Constructing the URL
To compose a new pre-filled topic, modify URL params like this:
https://discourse.example.com/new-topic?title=topic%20title&body=topic%20body&category=category/subcategory&tags=email,planned
This will open composer window pre filled with topic title, body, category and tags.
Breaking down the link / URL to show the available options, we have:
-
Base URL:
https://discourse.example.com/new-topic
-
Topic title:
title=topic%20title
-
Body:
body=topic%20body
- The category and subcategory separated by a slash
/
if you want to include them:category=category/subcategory
- The tags separated by comma(s)
,
if you want to include multiple tags:tags=email,planned
- The
?
URL operator to add the different options
You can try this here on Meta:
https://meta.discourse.org/new-topic?title=topic%20title&body=topic%20body&category=support/wordpress&tags=wordpress
Also, instead of providing category/subcategory name, you can also specify a numeric category_id
, like:
https://meta.discourse.org/new-topic?title=topic%20title&body=topic%20body&category_id=3&tags=wordpress
This feature also supports βStart a topic by pasting a link (like Reddit)β, provided that the body is not present.
The URL must be URL encoded for the link to work.
For example, to create a topic with the following URL https://www.xkcd.com/556
, the link will be:
https://meta.discourse.org/new-topic?title=https%3A%2F%2Fwww.xkcd.com%2F556
Best practices
- In general, if you have a lot of text to add, you can use w3Schoolsβs HTML URL Encoding Reference to find what text characters are encoded as in the URL, there is a text to URL converter in the
Try It Yourself
section in the page linked above in this paragraph. - Ensure that the pre-filled information is clear and structured to help users understand what to do.
- If youβre not sure about the category ID, you can verify it by inspecting the category URL or by checking the category settings in your Discourse instance.
- Always URL encode the parameters to avoid issues with special characters.
- Test the pre-filled links to ensure they work as expected in your Discourse instance.
Additional Resources
Last edited by @hugh 2024-06-28T02:53:56Z
Check document
Perform check on document: