Skip to content

Broken 'Edit on GitHub' link #1321

Closed
Closed

Description

@brianhlin

We recently updated to 0.17.0 and it seems to have broken our 'Edit on GitHub' link, you can see this in action here. The link given is https://github.com/edit/master/docs/index.md when it should be https://github.com/opensciencegrid/docs/edit/master/docs/index.md. repo_url appears to be set properly.

Activity

  1. waylan commented on Oct 23, 2017

    @waylan
    Contributor

    Thanks for the report. It appears that the problem presents itself if you are missing a closing slash at the end of the repo_url. Add the closing slash and it should work correctly:

    repo_url: https://github.com/opensciencegrid/docs/

    I'm just guessing, but it could be that the added support for fragment and query string based schemes was confused by the lack of a closing slash and messed things up. In any event, it appears that we only tested with the slash, not without. After all, MkDocs own config includes the slash and the example in the documentation shows a slash.

    I'm undecided if the closing slash should be a requirement. Although, apparently, it previously worked fine without it, so requiring it would be a regression for some users.

  2. brianhlin commented on Oct 23, 2017

    @brianhlin
    Author

    Does that mean the site_url should also have a trailing slash?

  3. waylan commented on Oct 23, 2017

    @waylan
    Contributor

    This is unique to repo_url. Consider the following examples:

    http://example.com/user/project?branch=master&action=edit&path=path/to/page.md
    http://example.com/user/project#branch/path/to/page.md
    http://example.com/user/project/edit/branch/path/to/page.md
    

    In the first two examples, the repo_url does not end in a slash, but it does in the third example. We support all three. So if your host uses a scheme which requires a slash between the repo_url and the edit_uri, then the setting should include one. However, if your host does not use a slash between the repo_url and the edit_uri, then your setting should not include one. At least that's how it currently works. The question is if that's how it should work.

  4. waylan commented on Oct 27, 2017

    @waylan
    Contributor

    I looked at the tests and realized that we were missing a test. We have a test were repo_url is set to http://example.com but not http://example.com/foo. The tests pass for the first one, but when I added the second, it failed. This is definitely a bug.

    We were also missing a test for http://example.com/foo/ (closing slash included) but that works as it should. For now, the workaround is to end the repo_url with a slash.

  5. added a commit that references this issue on Oct 27, 2017
    a8c01a0
  6. added a commit that references this issue on Oct 27, 2017
    f5b398c
  7. dbogatov commented on Dec 6, 2017

    @dbogatov

    @waylan

    My apologies for commenting on a closed issue.

    In my setup, mkdocs lives in a subdirectory of the repo.
    https://github.com/dbogatov/status-site/tree/master/articles

    This setup break edit links because it assumes the docs directory is in the root while it is not.
    What would be the best workaround in my case?

  8. waylan commented on Dec 6, 2017

    @waylan
    Contributor

    Then you will need to manually set the edit_uri to properly point to the location of your docs_dir. The "default" only works when you use a default setup. You are not using a default setup, so you need to configure for your setup.

  9. dbogatov commented on Dec 7, 2017

    @dbogatov

    @waylan

    Wonderful!
    Could you post a link to the documentation where this property is explained?
    I could not find myself.

  10. kr434975092 commented on Nov 1, 2025

    @kr434975092

    需要获取评论以分析问题解决过程

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions