[go: up one dir, main page]

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

The "Skip to content" link is invalid except in the top page #899

Closed
jessitron opened this issue Oct 12, 2018 · 3 comments
Closed

The "Skip to content" link is invalid except in the top page #899

jessitron opened this issue Oct 12, 2018 · 3 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@jessitron
Copy link

Description

HtmlProofer has kindly identified that every "Skip to content" link in my site is invalid except the top-level index. You can see this on your own site: right now, the https://squidfunk.github.io/mkdocs-material/customization/ page contains the link:

<a href="../#customization" tabindex="1" class="md-skip">
        Skip to content
      </a>

and ../#customization is invalid. It should be "#customization"

Expected behavior

All generated links on the page should be valid links.

Actual behavior

In this line of code:

<a href="{{ (page.toc | first).url | url }}" tabindex="1" class="md-skip">

it does:

href="{{ (page.toc | first).url | url }}"

and that url filter turns "#internal-anchor" into "../#internal-anchor" for a top-level non-index page like Customization. For a page deeper in the docs directory it puts more ../ path components.

Unfortunately the url filter thinks #internal-anchors are absolute from the base, or something. I reported it to mkdocs: mkdocs/mkdocs#1655 . There are no tests for that filter in the mkdocs repo :-(

meanwhile, you don't need to pass that url to that filter as far I can tell.

Steps to reproduce the bug

  1. Go to https://squidfunk.github.io/mkdocs-material/customization/
  2. Look at the HTML
  3. Search for "Skip to content"
  4. Observe the invalid href: "../#customization"

Currently, your gh-pages branch says: "Deployed fa8d490 with MkDocs version: 1.0.4"

Package versions

  • Python: 3.6.0
  • MkDocs: 1.0.4
  • Material: 3.0.4

Project configuration

... it shows up in your own ...

System information

  • OS: Mac
  • Browser: Firefox
@squidfunk
Copy link
Owner

Thanks for reporting, that's indeed a bug! We should just remove the filter, as you already said. I'm currently on holiday, so expect a fix to land at the end of next week.

PS: that's a great issue. Would love to see more written like this as opposed to "I have error pls fix thx"

@squidfunk squidfunk added the bug Issue reports a bug label Oct 18, 2018
@squidfunk
Copy link
Owner

Fixed in 13a76c4. Will be part of next release. Thanks for your time in researching the problem and solution!

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Oct 23, 2018
@squidfunk
Copy link
Owner

Released as part of 3.0.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants