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

allow redirecting of .html URLs (without producing a warning) #51

Open
boegel opened this issue Oct 24, 2022 · 5 comments
Open

allow redirecting of .html URLs (without producing a warning) #51

boegel opened this issue Oct 24, 2022 · 5 comments

Comments

@boegel
Copy link

boegel commented Oct 24, 2022

(see also PR #50)

I would like to use mkdocs-redirects in our effort to port our documentation from Sphinx/.rst (hosted at ReadTheDocs to MkDocs/.md (hosted at GitHub Pages), so we can avoid breaking our current documentation URLs.

This is actually working already, by using something like:

plugins:
  - redirects:
      redirect_maps:
        en/latest/example.html: example.md

This makes a URL like https://example.github.io/docs/en/latest/exampe.html redirect correctly to https://example.github.io/docs/example/.

The problem is that mkdocs-redirects currently logs a warning for redirects of non-MarkDown paths:

WARNING  -  redirects plugin: 'en/latest/example.html' is not a valid markdown file!

That's annoying, since we would like to use mkdocs build --strict in CI to test changes to our documentation, and that exits with a non-zero exit code as soon there as any warnings.

Two potential ways forward:

@boegel
Copy link
Author

boegel commented Jan 4, 2023

@oprypin Any thoughts on this?

@oprypin
Copy link
Contributor

oprypin commented Jan 4, 2023

Yeah this just needs to happen, even by default, I just haven't spent any time on this 😕

@boegel
Copy link
Author

boegel commented Jan 4, 2023

I'm happy to revisit my PR #50 to do this, would that help?

@CommunityUBC
Copy link

CommunityUBC commented May 12, 2024

We would also appreciate this fix! I see that this issue is a bit old, are there any new updates on this?

We migrated from mdBook which has a similar issue. For example:

        'academics/classes/textbooks.html': 'academics/classes/textbooks.md'

The redirect works, but the warning messages make it hard to spot other legitimate warnings

@pawamoy
Copy link
Contributor

pawamoy commented Oct 12, 2024

I'll add that there's an easy workaround:

plugins:
  - redirects:
      redirect_maps:
        en/latest/example.html.md: example.md

This will effectively create en/latest/example.html/index.html. Then if you go to en/latest/example.html, it redirects you to en/latest/example.html/, which redirects you again to example/.

No MkDocs warning 🙂

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

No branches or pull requests

4 participants