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

add 'allow_html_redirect' configuration option to avoid printing warning when redirecting .html URLs

Open boegel opened this issue 3 years ago • 4 comments

I'm porting documentation that currently uses Sphinx + .rst to MkDocs + md, and I would like to ensure that redirects are in place for old URLs like https://docs.easybuild.io/en/latest/Configuration.html.

To achieve this, I'm using mkdocs-redirects, as follows in mkdocs.yml:

plugins:
  - redirects:
      redirect_maps:
        en/latest/Configuration.html: configuring_easybuild.md

That's working fine (see https://easybuilders.github.io/easybuild-docs/en/latest/Configuration.html which correctly redirects), but mkdocs-redirects is logging warnings when .html URLs are redirected:

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

That's annoying, since I 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.

The changes being proposed here allow configuring mkdocs-redirects with allow_html_redirects to silence the warning:

plugins:
  - redirects:
      allow_html_redirect: True
      redirect_maps:
        en/latest/Configuration.html: configuring_easybuild.md

boegel avatar Oct 23 '22 08:10 boegel

I'm happy to make the extra effort in this PR to update the README file with a new section that documents this feature, and to implement a test to verify that the feature works as expected, but I would like to get some feedback first on whether this feature would be accepted for inclusing in mkdocs-redirects before doing so.

boegel avatar Oct 23 '22 08:10 boegel

Just a few days ago I was thinking that something like this would be good, because indeed, the current setup assumes you're migrating from an exact same MkDocs setup (even down to use_directory_urls). And I actually think this shouldn't even be behind a config. But I'll need to carefully look at the code myself first. It would be good to have this as an issue instead, to clearly define what use case we're solving. Though I see that in the description of your pull request you do define the use case very well, definitely thanks for that!

oprypin avatar Oct 23 '22 10:10 oprypin

@oprypin Thanks for the feedback, I've opened an issue for this at #51

boegel avatar Oct 24 '22 07:10 boegel

@oprypin what's the current status here?

jrappen avatar Jan 26 '23 19:01 jrappen