JSON link array does not match link order in post


We are using Discourse to power our Wiki. It’s been working pretty well. Since updating to 1.7 we’ve run in to a slight snag. It seems that the ordering of the links to other Wiki pages is not necessarily respected.

If you see our Table of Contents for the Wiki here, you will see that Apple TV is the second to last link, and we would like it to be the second to last category to appear. Our script scrapes the links array. I have noticed that the JSON of the post lists Apple TV first. At first I thought Discourse may be ordering links by post ID, but this does not seem to be the case. I tried editing the post and removing all links, and then re-adding them, but this did not change the situation.

Is there an explanation for how the links array is ordered? Would it make sense for the links to be listed in the JSON in the order that they are referenced?

        "title":"Apple TV",




1 Like

I believe those links are ordered in terms of popularity. The most clicked on links will be at the top.





Thanks for the information. I’ll have to find an appropriate workaround.


You have link_counts, so you could add correct ordering there, but preserve links as is in a future version of Discourse, or maybe add a ‘links_raw’. If you would accept a new JSON property that offers links in the correct order then I can PR this.

I will have to work around this temporarily by taking cooked and taking links from that or patching Discourse.