You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
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.
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.
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.
Activity
waylan commentedon Oct 23, 2017
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:
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.
brianhlin commentedon Oct 23, 2017
Does that mean the
site_urlshould also have a trailing slash?Fix 'Edit Github links' (closing slashes required)
waylan commentedon Oct 23, 2017
This is unique to
repo_url. Consider the following examples:In the first two examples, the
repo_urldoes 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 therepo_urland theedit_uri, then the setting should include one. However, if your host does not use a slash between therepo_urland theedit_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.Fix 'Edit Github links' (closing slashes required)
Fix 'Edit on GitHub links' (closing slashes required)
Fix 'Edit on GitHub' links
Fix 'Edit on GitHub' links
Fix 'Edit on GitHub' links
Fix 'Edit on GitHub' links
Fix 'Edit on GitHub' links
waylan commentedon Oct 27, 2017
I looked at the tests and realized that we were missing a test. We have a test were
repo_urlis set tohttp://example.combut nothttp://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 therepo_urlwith a slash.Support `repo_url` with missing ending slash.
Support `repo_url` with missing ending slash.
dbogatov commentedon Dec 6, 2017
@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?
waylan commentedon Dec 6, 2017
Then you will need to manually set the
edit_urito properly point to the location of yourdocs_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.dbogatov commentedon Dec 7, 2017
@waylan
Wonderful!
Could you post a link to the documentation where this property is explained?
I could not find myself.
waylan commentedon Dec 7, 2017
@dbogatov http://www.mkdocs.org/user-guide/configuration/#edit_uri
kr434975092 commentedon Nov 1, 2025
需要获取评论以分析问题解决过程