Suggest an enhancement to the 404 page

Hi.

I would like to make a suggestion to enhance the page returned for file not found errors (404). The 3D effect on the picture is quite nice, by the way.

Consider this page, for example:

https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/cuvid.c

Recently, the file was renamed cuviddec.c, hence the 404. It would be nice if the returned page included useful links. In this example, that would be:

https://github.com/FFmpeg/ (the owner dashboard)
https://github.com/FFmpeg/FFmpeg/ (the corresponding repository)
https://github.com/FFmpeg/FFmpeg/commits/master/libavcodec/cuvid.c (the history of the file, valid even after the file was renamed)

This would help people who arrived there following an obsolete link from outside to find their way back to something useful.

Expressed as a set of rules, it would be:

If $request_path matches the regexp ^/([^/]+)/ then add a link to /$1/.

If $request_path matches the regexp ^/([^/]+)/([^/]+)/ then add a link to /$1/$2/.

If $request_path matches the regexp ^/([^/]+)/([^/]+)/blob/(.*) then add a link to /$1/$2/commits/$3.

Note that this could be done purely on client side. In fact, once I am done with this mail I will endeavour to write a greasemonkey script or bookmarklet to do just that. But I think it would be more convenient for visitors to have it by default.

Regards,


Nicolas George

And done with Greasemonkey. Feel free to consider it public domain. But I still think it would be better if it was included by default.

// ==UserScript==
// @name github_404
// @namespace cigaes.org
// @include https://github.com/*
// @version 1
// @grant none
// ==/UserScript==

(function () {

  if (document.title.match(/^Page not found · GitHub/)) {
    var loc = "" + document.location;
    var links = [];
    var m = loc.match(/^(\w+:\/\/[^\/]+)\/([^\/]+)\//);
    if (m)
      links.push({ url: m[1] + "/" + m[2] + "/", label: "User page" });
    var m = loc.match(/^(\w+:\/\/[^\/]+)\/([^\/]+)\/([^\/]+)\//);
    if (m)
      links.push({ url: m[1] + "/" + m[2] + "/" + m[3] + "/",
        label: "Repository" });
    var m = loc.match(/^(\w+:\/\/[^\/]+)\/([^\/]+)\/([^\/]+)\/blob\/(.*)/);
    if (m)
      links.push({ url: m[1] + "/" + m[2] + "/" + m[3] + "/commits/" + m[4],
        label: "File history" });
    var p = document.createElement("p");
    p.style.position = "fixed";
    p.style.left = "1em";
    p.style.bottom = "1em";
    p.style.border = "solid 1px black";
    p.style.padding = "1ex";
    for (var i = 0; i < links.length; i++) {
      if (i > 0)
        p.appendChild(document.createElement("br"));
      var a = document.createElement("a");
      a.href = links[i].url;
      a.appendChild(document.createTextNode(links[i].label));
      p.appendChild(a);
    }
    document.body.appendChild(p);
  }

})();

Hi @cigaes,

Thanks for this feedback! We’re always working to improve GitHub and the GitHub Community Forum, and we consider every suggestion we receive.

The way that GitHub currently uses 404 errors compensates for a number of different scenarios, including resources that are no longer available, resources that the user does not have access to (to prevent revealing the existance of such resources), and to obscure the inner workings of GitHub itself to increase security. 

However, that does not mean that improvements could not be made and I’ve logged your feature request in our internal feature request list. Though I can’t guarantee anything or share a timeline for this, I can tell you that it’s been shared with the appropriate teams for consideration.

Please let me know if you have any other questions.

Thanks!

2 Likes

Absolutely +1 this! One of the biggest annoyances with using history links in browser that lead to long  gone branches sometimes, is going to the address bar and removing things from the URL to get to the project root page. Would love to have a link “404, but go to the repo root”