Custom permalinks

faq-material

(Hosein Naseri) #1

There is a permalink tab under customize section in admin panel. I don’t know what does it exactly do. Can someone please explain it to me with a picture from that area? Because I have my discourse in Persian, and Persian translation of different fields in this section doesn’t make sense to me.


(Arpit Jalan) #2

See:

and


(Hosein Naseri) #3

thanks.
How can I programmatically create these permalinks? php code is preferred for me. is it possible?

I want to use discourse as a q&a platform in my educational app. My app has a structure like this:
course/chapter/lesson
So I want the users to be able to create new topics like this:
course/chapter/lesson/topic-1
course/chapter/lesson/topic-2
etc…
since this structure isn’t supported by discourse, I want to use this customized permalinks as a redirection tool to created topics. Is it a good idea?


(Felix Freiberger) #4

You can use the API to create these. Create a permalink while the Network tab of your browser’s development tools is open to see how it works. You can find more details here:


(Neil Lalonde) #5

There’s a post in the linked topic with an example:

Permalink.create(url: '/discussion/12345', topic_id: 987)

(Ivan Rapekas) #6

Let me add my 50 cents to the topic.If Discourse runs from folder, for example https://example.com/forum, then the permalink should contain folder at the beginning:

Old URL: external-filesrecord-sets
Permalink: forum/external-filesrecord-sets
Topic ID: 88 --> New URL: /forum/t/external-files-record-sets/88


#7

Help, please! :slight_smile:

  1. How can one find out what the post/topic/category ID is, without using code?

  2. I’m trying to create redirects from the admin/permalink panel and I’m doing something wrong. Is anyone able to do one example with me in private?


(Mittineague) #8

I don’t know enough about permalink redirections to comment.

But you should be able to get category ids from
.../site.json


#9

Thank you for the help.

I’m getting an error: {“errors”:[“The requested URL or resource could not be found.”],“error_type”:“not_found”}


#10

This issue still remains. Would love to get some help here :slight_smile:


#11

This doesn’t work.

It seems also that the problem with permalinks on my end is the RTL.

Some links include RTL and it causes issues.