Meta links to Github often broken

You can find a lot of references to code in github as you browse through, but many of the links no longer work…

I think one solution would be to require that a github permalink is posted (or at least warn the poster when their github link is not a permalink).

I’ve come across dozens of them today. For example, see “How Discourse Stays Online - (Message Bus, Faye, Long Polling)

You just hit y to get a Permalink on Github.

So many broken links makes meta more difficult to use. Considering these links are typically posted by the Discourse founders, all the more likely to be followed into the future…

There are probably some exceptions that you’re 99% sure will stay around, such as, but search for “” and see how many of these are no longer valid.

1 Like

I don’t know when the permalink feature was added but I only knew about it with this announcement

The post you mentioned is far older than that announcement :wink:


Yes, links break over time. This is not specific to meta, or Discourse, or even Github. Does Github provide a stable means of determining whether a URL is a permalink based on its structure? If not, it’s going to be awfully tricky to implement a warning.


If you have a URL with this format:

You can figure out if it’s a permalink by hitting this URL:

If the returned SHA is equal to :commit itself, then it’s a permalink. Otherwise, it’s not. Personally, I’d just rewrite non-permalinks into permalinks automatically, though.


There doesn’t seem to be a straightforward way to get a permanent link from the entered GitHub link if we wanted to rewrite links into permalink automatically. I guess checking if the link is permalink like @notriddle suggested and adding a warning would be a way to go here?


Actually, it’s fairly easy to come up with the permanent link if you’re parsing out the URL as they suggested.

Just replace the :commit segment with the actual commit hash you get back from the API. (And re-attach the query and anchor strings.)

1 Like

Can you give us a fully-worked example of how to go from a /tree/ link to a /blob/ link programmatically? I can’t figure it out from the examples provided.


This is now available in the new discourse-github plugin.

Github Permalink

Replace Github non-permalinks with permalinks.

How to use:

  1. Enable github permalinks enabled in Settings -> Plugins.

This topic was automatically closed after 46 hours. New replies are no longer allowed.