mkdocs-redirects icon indicating copy to clipboard operation
mkdocs-redirects copied to clipboard

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

Open boegel opened this issue 3 years ago • 5 comments

(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:

  • disable the warning for .html paths (since it works fine);
  • add support for a way to opt-in to redirecting .html paths, through a configuration option like allow_html_redirect (implemented in #50);

boegel avatar Oct 24 '22 07:10 boegel

@oprypin Any thoughts on this?

boegel avatar Jan 04 '23 15:01 boegel

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

oprypin avatar Jan 04 '23 17:01 oprypin

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

boegel avatar Jan 04 '23 18:01 boegel

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

CommunityUBC avatar May 12 '24 09:05 CommunityUBC