Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative links in pages below the top-level document folder point to the wrong path #292

Closed
jdhoek opened this issue Dec 18, 2014 · 10 comments
Closed
Labels
Bug
Milestone

Comments

@jdhoek
Copy link

@jdhoek jdhoek commented Dec 18, 2014

Relative image links in pages below the top-level document folder seem to point to the wrong path.

Reproduction

I've created a minimal reproduction case:
https://github.com/jdhoek/mkdocs-test-relative-image-links

The reproduction case contains this file structure:

├── docs
│   ├── index.md
│   ├── subdir
│   │   ├── sub.md
│   │   └── sub.png
│   └── toplevel.png
└── mkdocs.yml

mkdocs serve and mkdocs build correctly process the Markdown files in the top-level folder docs_dir, but with the Markdown file in the sub-folder the relative image links are broken.

mkdocs-relative-image-links

@tomchristie
Copy link
Contributor

@tomchristie tomchristie commented Dec 18, 2014

Probably same as #77 but this is more helpful.

@jdhoek
Copy link
Author

@jdhoek jdhoek commented Dec 18, 2014

I wasn't sure if #77 was the exact same issue. Thanks for referencing it.

@d0ugal
Copy link
Member

@d0ugal d0ugal commented Dec 18, 2014

This is a great report, thanks very much.

Things gets a bit confusing as, I think, we have links in three different scenarios.

  • Links to markdown (as far as I'm aware, no known issues)
  • Links to static assets like images (this issue)
  • Either of the above on a "static page" like the 404.html which could be returned under many paths. (this is probably #77).

The first two vary because we move the location of markdown files (my/document.md becomes my/document/index.html and is thus one level deeper). So, these issues are probably subtly different but I expect a fix will need to take all the above into account.

@jdhoek Just to check, did you test this against the latest release or via git master? There was some fairly recent fixes for images, but I can't remember if it made the last release or not :)

@d0ugal
Copy link
Member

@d0ugal d0ugal commented Dec 18, 2014

... I just confirmed, it is still an issue with the latest dev version.

@d0ugal
Copy link
Member

@d0ugal d0ugal commented Dec 18, 2014

I can't see an obvious reason, but the broken image path is coming out as ../../sub.png when it should be ../sub.png.

@d0ugal d0ugal added the Bug label Dec 18, 2014
@d0ugal d0ugal added this to the 0.12.0 milestone Dec 18, 2014
@d0ugal
Copy link
Member

@d0ugal d0ugal commented Dec 18, 2014

Gah, I see the issue with images. It comes down to my miss-understanding of the url rewriting when I added support for them. it is actually a coincidence that any of these work. 😳

Clearly the tests I added for this are completely bogus. I'll look into a real fix.

Using create_media_urls here is completely wrong. https://github.com/tomchristie/mkdocs/blob/aaf344630f4732ae58d1da28b25d0c02bd8d56b9/mkdocs/relative_path_ext.py#L59

@jdhoek
Copy link
Author

@jdhoek jdhoek commented Dec 18, 2014

@d0ugal
My apologies, I should have mentioned the version. I am using the latest stable release from PyPI; v0.11.1.

d0ugal added a commit to d0ugal/mkdocs that referenced this issue Dec 19, 2014
@d0ugal d0ugal closed this in #293 Dec 20, 2014
@Mopster
Copy link

@Mopster Mopster commented Apr 2, 2015

I came across this problem today, any eta on v0.12 ? :-) Currently I have to choose between working images in the GitHub repo or on the generated site :-)

Mopster pushed a commit to axsh/wakame-vdc that referenced this issue Apr 2, 2015
@d0ugal
Copy link
Member

@d0ugal d0ugal commented Apr 2, 2015

@Mopster The 0.12.0 milestone is here. I've got it down to just a smallish number of bugs. https://github.com/mkdocs/mkdocs/milestones/0.12.0 - I am hoping to do it this weekend, but no guarantees ;)

@Mopster
Copy link

@Mopster Mopster commented Apr 2, 2015

great! gonna show it off to the office today ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants
You can’t perform that action at this time.